StarryNights

每一个你所后悔的现在,都有一个不够努力的曾经

站内检索

循着字句,邂逅星光

搜索文章标题与正文,直达命中的章节

开始一次轻盈的站内探索

从这些主题开始探索

输入关键词

可同时输入多个词语缩小范围

发现内容

在摘要中查看高亮的关键词

快速直达

点击文章或章节标题继续阅读

3.1k字4 分钟

# 引言 题目链接:https://leetcode.com/problems/3sum-closest/description/ # 题目大意 给出一个包含n个整数的数组nums和一个目标数字target, 在数组中找到三个整数使得它们的总和最接近目标target, 输出这个最接近目标值的数字 Example Given array nums = [-1, 2, 1, -4], and target = 1. The sum that is closest to the target is 2. (-1 +
3.2k字4 分钟

# 引言 题目链接:https://leetcode.com/problems/3sum/description/ # 题目大意 给出一个包含n个整数的数组nums, 这个数组是否存在元素有a,b,c使得a + b + c = 0, 找出所有满足条件的a,b,c的组合 Example Given array nums = [-1, 0, 1, 2, -1, -4], A solution set is: [ [-1, 0, 1], [-1, -1, 2] ] # 题解 很容易想到暴力解法, 三重循环穷
2.1k字3 分钟

# 引言 题目链接:https://leetcode.com/problems/integer-to-roman/description/ # 题目大意 输入一个整型数字, 将这个数字转换为罗马数字 有如下约定 Symbol Value I 1 V 5 X 10 L 50 C 100 D 500 M 1000 I can be placed before
2.1k字3 分钟

# 引言 题目链接:https://leetcode.com/problems/roman-to-integer/description/ # 题目大意 给出一个罗马数字, 将这个罗马数字转换为数字 有如下约定 Symbol Value I 1 V 5 X 10 L 50 C 100 D 500 M 1000 Roman numerals are usua
1.8k字2 分钟

# 引言 题目链接:https://leetcode.com/problems/longest-common-prefix/description/ # 题目大意 给出一串单词, 编写一个函数找到这串单词的最长公共前缀 **Hint:**If there is no common prefix, return an empty string "". Example Input: ["flower","flow","flight"] Output: &q
4.5k字6 分钟

# 引言 题目链接:https://leetcode.com/problems/regular-expression-matching/description/ # 题目大意 给定一个输入字符, 和一个匹配模式p, 实现正则表达式的匹配, 匹配模式支持'.'和'*' '.' 匹配任何单个的字符 '*' 匹配前一个元素n次(n>=0) 要求模式p的匹配覆盖整个输入字符串, 而不是部分匹配 Example Input: s = "aa&
1.2k字2 分钟

# 引言 题目链接:https://leetcode.com/problems/palindrome-number/description/ # 题目大意 判断一个数字是不是回文数字。 Example Input: 121 Output: true Input: -121 Output: false Explanation: From left to right, it reads -121. From right to left, it becomes 121-. Therefore it is not a palindrom
2.7k字4 分钟

# 引言 题目链接:https://leetcode.com/problems/string-to-integer-atoi/description/ # 题目大意 实现一个atoi函数。输入一串字符串, 扫描字符串, 跳过前面的空格, 直到遇上数字或正负符号才开始做转换, 而再遇到非数字或字符串结束时('\0')才结束转换, 并将结果返回。 Example Input: "42" Output: 42 Input: "words and 987" Output: 0 Ex
1.4k字2 分钟

# 引言 题目链接:https://leetcode.com/problems/reverse-integer/description/ # 题目大意 给出一个32位整型数字(int32), 输出这个数字翻转后的数字。 Example1 Input: 123 Output: 321 Example2 Input: -123 Output: -321 Example3 Input: 120 Output: 21 **Hint** `For the purpose of this problem, assume t
2.2k字3 分钟

# 引言 题目链接:https://leetcode.com/problems/zigzag-conversion/description/ # 题目大意 给出一个字符串, 和一个指定行数, 将字符串纵向按照z字形排列(指定行数为z字形大小) Example s = "PAYPALISHIRING", numRows = 3 Output: "PAHNAPLSIIGYIR" Z字形排列图 P A H N A P L S I I G Y I R # 题