Skip to content

Commit 1f8f97f

Browse files
committed
update readme
1 parent dd5b9ac commit 1f8f97f

File tree

86 files changed

+4696
-27
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+4696
-27
lines changed

Diff for: README.md

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
[![Travis](https://www.travis-ci.org/lxlxw/leetcode.svg?branch=master)](https://www.travis-ci.org/lxlxw/leetcode)
66
[![Codecov](https://codecov.io/gh/lxlxw/leetcode/branch/master/graph/badge.svg)](https://codecov.io/gh/lxlxw/leetcode)
77
[![MIT License](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
8+
[![Go](https://img.shields.io/badge/Go-1.12-blue.svg)](https://golang.google.cn)
9+
[![Go](https://img.shields.io/badge/Go-1.13-blue.svg)](https://golang.google.cn)
810
[![HitCount](http://hits.dwyl.com/lxlxw/leetcode.svg)](http://hits.dwyl.com/lxlxw/leetcode)
911

1012
[ [中文](http://leetcode.xwlin.com)

Diff for: _sidebar.md

+1,002-26
Large diffs are not rendered by default.

Diff for: contributor.md

-1
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# [3. 无重复字符的最长子串](https://leetcode-cn.com/problems/longest-substring-without-repeating-characters)
2+
3+
## 题目描述
4+
<!-- 这里写题目描述 -->
5+
<p>给定一个字符串,请你找出其中不含有重复字符的&nbsp;<strong>最长子串&nbsp;</strong>的长度。</p>
6+
7+
<p><strong>示例&nbsp;1:</strong></p>
8+
9+
<pre><strong>输入: </strong>&quot;abcabcbb&quot;
10+
<strong>输出: </strong>3
11+
<strong>解释:</strong> 因为无重复字符的最长子串是 <code>&quot;abc&quot;,所以其</code>长度为 3。
12+
</pre>
13+
14+
<p><strong>示例 2:</strong></p>
15+
16+
<pre><strong>输入: </strong>&quot;bbbbb&quot;
17+
<strong>输出: </strong>1
18+
<strong>解释: </strong>因为无重复字符的最长子串是 <code>&quot;b&quot;</code>,所以其长度为 1。
19+
</pre>
20+
21+
<p><strong>示例 3:</strong></p>
22+
23+
<pre><strong>输入: </strong>&quot;pwwkew&quot;
24+
<strong>输出: </strong>3
25+
<strong>解释: </strong>因为无重复字符的最长子串是&nbsp;<code>&quot;wke&quot;</code>,所以其长度为 3。
26+
&nbsp; 请注意,你的答案必须是 <strong>子串 </strong>的长度,<code>&quot;pwke&quot;</code>&nbsp;是一个<em>子序列,</em>不是子串。
27+
</pre>
28+
29+
30+
31+
### 解题思路
32+
33+
34+
### 具体解法
35+
36+
<!-- tabs:start -->
37+
38+
#### **Golang**
39+
```go
40+
41+
```
42+
43+
<!-- tabs:end -->
+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# [4. 寻找两个有序数组的中位数](https://leetcode-cn.com/problems/median-of-two-sorted-arrays)
2+
3+
## 题目描述
4+
<!-- 这里写题目描述 -->
5+
<p>给定两个大小为 m 和 n 的有序数组&nbsp;<code>nums1</code> 和&nbsp;<code>nums2</code>。</p>
6+
7+
<p>请你找出这两个有序数组的中位数,并且要求算法的时间复杂度为&nbsp;O(log(m + n))。</p>
8+
9+
<p>你可以假设&nbsp;<code>nums1</code>&nbsp;&nbsp;<code>nums2</code>&nbsp;不会同时为空。</p>
10+
11+
<p><strong>示例 1:</strong></p>
12+
13+
<pre>nums1 = [1, 3]
14+
nums2 = [2]
15+
16+
则中位数是 2.0
17+
</pre>
18+
19+
<p><strong>示例 2:</strong></p>
20+
21+
<pre>nums1 = [1, 2]
22+
nums2 = [3, 4]
23+
24+
则中位数是 (2 + 3)/2 = 2.5
25+
</pre>
26+
27+
28+
29+
### 解题思路
30+
31+
32+
### 具体解法
33+
34+
<!-- tabs:start -->
35+
36+
#### **Golang**
37+
```go
38+
39+
```
40+
41+
<!-- tabs:end -->
42+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# [5. 最长回文子串](https://leetcode-cn.com/problems/longest-palindromic-substring)
2+
3+
## 题目描述
4+
<!-- 这里写题目描述 -->
5+
<p>给定一个字符串 <code>s</code>,找到 <code>s</code> 中最长的回文子串。你可以假设&nbsp;<code>s</code> 的最大长度为 1000。</p>
6+
7+
<p><strong>示例 1:</strong></p>
8+
9+
<pre><strong>输入:</strong> &quot;babad&quot;
10+
<strong>输出:</strong> &quot;bab&quot;
11+
<strong>注意:</strong> &quot;aba&quot; 也是一个有效答案。
12+
</pre>
13+
14+
<p><strong>示例 2:</strong></p>
15+
16+
<pre><strong>输入:</strong> &quot;cbbd&quot;
17+
<strong>输出:</strong> &quot;bb&quot;
18+
</pre>
19+
20+
21+
22+
### 解题思路
23+
24+
25+
### 具体解法
26+
27+
<!-- tabs:start -->
28+
29+
#### **Golang**
30+
```go
31+
32+
```
33+
34+
<!-- tabs:end -->
35+

Diff for: solution/1-99/0006.zigzag-conversion/README.md

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# [6. Z 字形变换](https://leetcode-cn.com/problems/zigzag-conversion)
2+
3+
## 题目描述
4+
<!-- 这里写题目描述 -->
5+
<p>将一个给定字符串根据给定的行数,以从上往下、从左到右进行&nbsp;Z 字形排列。</p>
6+
7+
<p>比如输入字符串为 <code>&quot;LEETCODEISHIRING&quot;</code>&nbsp;行数为 3 时,排列如下:</p>
8+
9+
<pre>L C I R
10+
E T O E S I I G
11+
E D H N
12+
</pre>
13+
14+
<p>之后,你的输出需要从左往右逐行读取,产生出一个新的字符串,比如:<code>&quot;LCIRETOESIIGEDHN&quot;</code>。</p>
15+
16+
<p>请你实现这个将字符串进行指定行数变换的函数:</p>
17+
18+
<pre>string convert(string s, int numRows);</pre>
19+
20+
<p><strong>示例&nbsp;1:</strong></p>
21+
22+
<pre><strong>输入:</strong> s = &quot;LEETCODEISHIRING&quot;, numRows = 3
23+
<strong>输出:</strong> &quot;LCIRETOESIIGEDHN&quot;
24+
</pre>
25+
26+
<p><strong>示例&nbsp;2:</strong></p>
27+
28+
<pre><strong>输入:</strong> s = &quot;LEETCODEISHIRING&quot;, numRows =&nbsp;4
29+
<strong>输出:</strong>&nbsp;&quot;LDREOEIIECIHNTSG&quot;
30+
<strong>解释:</strong>
31+
32+
L D R
33+
E O E I I
34+
E C I H N
35+
T S G</pre>
36+
37+
38+
39+
### 解题思路
40+
41+
42+
### 具体解法
43+
44+
<!-- tabs:start -->
45+
46+
#### **Golang**
47+
```go
48+
49+
```
50+
51+
<!-- tabs:end -->
52+

Diff for: solution/1-99/0008.string-to-integer-atoi/README.md

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# [8. 字符串转换整数 (atoi)](https://leetcode-cn.com/problems/string-to-integer-atoi)
2+
3+
## 题目描述
4+
<!-- 这里写题目描述 -->
5+
<p>请你来实现一个&nbsp;<code>atoi</code>&nbsp;函数,使其能将字符串转换成整数。</p>
6+
7+
<p>首先,该函数会根据需要丢弃无用的开头空格字符,直到寻找到第一个非空格的字符为止。</p>
8+
9+
<p>当我们寻找到的第一个非空字符为正或者负号时,则将该符号与之后面尽可能多的连续数字组合起来,作为该整数的正负号;假如第一个非空字符是数字,则直接将其与之后连续的数字字符组合起来,形成整数。</p>
10+
11+
<p>该字符串除了有效的整数部分之后也可能会存在多余的字符,这些字符可以被忽略,它们对于函数不应该造成影响。</p>
12+
13+
<p>注意:假如该字符串中的第一个非空格字符不是一个有效整数字符、字符串为空或字符串仅包含空白字符时,则你的函数不需要进行转换。</p>
14+
15+
<p>在任何情况下,若函数不能进行有效的转换时,请返回 0。</p>
16+
17+
<p><strong>说明:</strong></p>
18+
19+
<p>假设我们的环境只能存储 32 位大小的有符号整数,那么其数值范围为&nbsp;[&minus;2<sup>31</sup>,&nbsp; 2<sup>31&nbsp;</sup>&minus; 1]。如果数值超过这个范围,请返回 &nbsp;INT_MAX (2<sup>31&nbsp;</sup>&minus; 1) 或&nbsp;INT_MIN (&minus;2<sup>31</sup>) 。</p>
20+
21+
<p><strong>示例&nbsp;1:</strong></p>
22+
23+
<pre><strong>输入:</strong> &quot;42&quot;
24+
<strong>输出:</strong> 42
25+
</pre>
26+
27+
<p><strong>示例&nbsp;2:</strong></p>
28+
29+
<pre><strong>输入:</strong> &quot; -42&quot;
30+
<strong>输出:</strong> -42
31+
<strong>解释: </strong>第一个非空白字符为 &#39;-&#39;, 它是一个负号。
32+
&nbsp; 我们尽可能将负号与后面所有连续出现的数字组合起来,最后得到 -42 。
33+
</pre>
34+
35+
<p><strong>示例&nbsp;3:</strong></p>
36+
37+
<pre><strong>输入:</strong> &quot;4193 with words&quot;
38+
<strong>输出:</strong> 4193
39+
<strong>解释:</strong> 转换截止于数字 &#39;3&#39; ,因为它的下一个字符不为数字。
40+
</pre>
41+
42+
<p><strong>示例&nbsp;4:</strong></p>
43+
44+
<pre><strong>输入:</strong> &quot;words and 987&quot;
45+
<strong>输出:</strong> 0
46+
<strong>解释:</strong> 第一个非空字符是 &#39;w&#39;, 但它不是数字或正、负号。
47+
因此无法执行有效的转换。</pre>
48+
49+
<p><strong>示例&nbsp;5:</strong></p>
50+
51+
<pre><strong>输入:</strong> &quot;-91283472332&quot;
52+
<strong>输出:</strong> -2147483648
53+
<strong>解释:</strong> 数字 &quot;-91283472332&quot; 超过 32 位有符号整数范围。
54+
&nbsp; 因此返回 INT_MIN (&minus;2<sup>31</sup>) 。
55+
</pre>
56+
57+
58+
59+
### 解题思路
60+
61+
62+
### 具体解法
63+
64+
<!-- tabs:start -->
65+
66+
#### **Golang**
67+
```go
68+
69+
```
70+
71+
<!-- tabs:end -->
+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# [10. 正则表达式匹配](https://leetcode-cn.com/problems/regular-expression-matching)
2+
3+
## 题目描述
4+
<!-- 这里写题目描述 -->
5+
<p>给你一个字符串&nbsp;<code>s</code>&nbsp;和一个字符规律&nbsp;<code>p</code>,请你来实现一个支持 <code>&#39;.&#39;</code>&nbsp;&nbsp;<code>&#39;*&#39;</code>&nbsp;的正则表达式匹配。</p>
6+
7+
<pre>&#39;.&#39; 匹配任意单个字符
8+
&#39;*&#39; 匹配零个或多个前面的那一个元素
9+
</pre>
10+
11+
<p>所谓匹配,是要涵盖&nbsp;<strong>整个&nbsp;</strong>字符串&nbsp;<code>s</code>的,而不是部分字符串。</p>
12+
13+
<p><strong>说明:</strong></p>
14+
15+
<ul>
16+
<li><code>s</code>&nbsp;可能为空,且只包含从&nbsp;<code>a-z</code>&nbsp;的小写字母。</li>
17+
<li><code>p</code>&nbsp;可能为空,且只包含从&nbsp;<code>a-z</code>&nbsp;的小写字母,以及字符&nbsp;<code>.</code>&nbsp;和&nbsp;<code>*</code>。</li>
18+
</ul>
19+
20+
<p><strong>示例 1:</strong></p>
21+
22+
<pre><strong>输入:</strong>
23+
s = &quot;aa&quot;
24+
p = &quot;a&quot;
25+
<strong>输出:</strong> false
26+
<strong>解释:</strong> &quot;a&quot; 无法匹配 &quot;aa&quot; 整个字符串。
27+
</pre>
28+
29+
<p><strong>示例 2:</strong></p>
30+
31+
<pre><strong>输入:</strong>
32+
s = &quot;aa&quot;
33+
p = &quot;a*&quot;
34+
<strong>输出:</strong> true
35+
<strong>解释:</strong>&nbsp;因为 &#39;*&#39; 代表可以匹配零个或多个前面的那一个元素, 在这里前面的元素就是 &#39;a&#39;。因此,字符串 &quot;aa&quot; 可被视为 &#39;a&#39; 重复了一次。
36+
</pre>
37+
38+
<p><strong>示例&nbsp;3:</strong></p>
39+
40+
<pre><strong>输入:</strong>
41+
s = &quot;ab&quot;
42+
p = &quot;.*&quot;
43+
<strong>输出:</strong> true
44+
<strong>解释:</strong>&nbsp;&quot;.*&quot; 表示可匹配零个或多个(&#39;*&#39;)任意字符(&#39;.&#39;)。
45+
</pre>
46+
47+
<p><strong>示例 4:</strong></p>
48+
49+
<pre><strong>输入:</strong>
50+
s = &quot;aab&quot;
51+
p = &quot;c*a*b&quot;
52+
<strong>输出:</strong> true
53+
<strong>解释:</strong>&nbsp;因为 &#39;*&#39; 表示零个或多个,这里 &#39;c&#39; 为 0 个, &#39;a&#39; 被重复一次。因此可以匹配字符串 &quot;aab&quot;
54+
</pre>
55+
56+
<p><strong>示例 5:</strong></p>
57+
58+
<pre><strong>输入:</strong>
59+
s = &quot;mississippi&quot;
60+
p = &quot;mis*is*p*.&quot;
61+
<strong>输出:</strong> false</pre>
62+
63+
64+
### 解题思路
65+
66+
67+
### 具体解法
68+
69+
<!-- tabs:start -->
70+
71+
#### **Golang**
72+
```go
73+
74+
```
75+
76+
<!-- tabs:end -->
77+
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# [11. 盛最多水的容器](https://leetcode-cn.com/problems/container-with-most-water)
2+
3+
## 题目描述
4+
<!-- 这里写题目描述 -->
5+
<p>给你 <em>n</em> 个非负整数 <em>a</em><sub>1</sub>,<em>a</em><sub>2,</sub>...,<em>a</em><sub>n,</sub>每个数代表坐标中的一个点&nbsp;(<em>i</em>,&nbsp;<em>a<sub>i</sub></em>) 。在坐标内画 <em>n</em> 条垂直线,垂直线 <em>i</em>&nbsp;的两个端点分别为&nbsp;(<em>i</em>,&nbsp;<em>a<sub>i</sub></em>) 和 (<em>i</em>, 0)。找出其中的两条线,使得它们与&nbsp;<em>x</em>&nbsp;轴共同构成的容器可以容纳最多的水。</p>
6+
7+
<p><strong>说明:</strong>你不能倾斜容器,且&nbsp;<em>n</em>&nbsp;的值至少为 2。</p>
8+
9+
<p>&nbsp;</p>
10+
11+
<p><img alt="" src="https://aliyun-lc-upload.oss-cn-hangzhou.aliyuncs.com/aliyun-lc-upload/uploads/2018/07/25/question_11.jpg" style="height: 287px; width: 600px;"></p>
12+
13+
<p><small>图中垂直线代表输入数组 [1,8,6,2,5,4,8,3,7]。在此情况下,容器能够容纳水(表示为蓝色部分)的最大值为&nbsp;49。</small></p>
14+
15+
<p>&nbsp;</p>
16+
17+
<p><strong>示例:</strong></p>
18+
19+
<pre><strong>输入:</strong>[1,8,6,2,5,4,8,3,7]
20+
<strong>输出:</strong>49</pre>
21+
22+
23+
24+
### 解题思路
25+
26+
27+
### 具体解法
28+
29+
<!-- tabs:start -->
30+
31+
#### **Golang**
32+
```go
33+
34+
```
35+
36+
<!-- tabs:end -->

0 commit comments

Comments
 (0)