Skip to content

Commit

Permalink
feat: update leetcode problems description
Browse files Browse the repository at this point in the history
  • Loading branch information
yanglbme committed Apr 21, 2021
1 parent 90b3883 commit 44dc9b6
Show file tree
Hide file tree
Showing 3,418 changed files with 74,489 additions and 74,375 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
43 changes: 37 additions & 6 deletions solution/0000-0099/0001.Two Sum/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,49 @@
## 题目描述

<!-- 这里写题目描述 -->
<p>给定一个整数数组 <code>nums</code>&nbsp;和一个目标值 <code>target</code>,请你在该数组中找出和为目标值的那&nbsp;<strong>两个</strong>&nbsp;整数,并返回他们的数组下标。</p>

<p>你可以假设每种输入只会对应一个答案。但是,你不能重复利用这个数组中同样的元素。</p>
<p>给定一个整数数组 <code>nums</code> 和一个整数目标值 <code>target</code>,请你在该数组中找出 <strong>和为目标值</strong> 的那 <strong>两个</strong> 整数,并返回它们的数组下标。</p>

<p><strong>示例:</strong></p>
<p>你可以假设每种输入只会对应一个答案。但是,数组中同一个元素在答案里不能重复出现。</p>

<pre>给定 nums = [2, 7, 11, 15], target = 9
<p>你可以按任意顺序返回答案。</p>

因为 nums[<strong>0</strong>] + nums[<strong>1</strong>] = 2 + 7 = 9
所以返回 [<strong>0, 1</strong>]
<p> </p>

<p><strong>示例 1:</strong></p>

<pre>
<strong>输入:</strong>nums = [2,7,11,15], target = 9
<strong>输出:</strong>[0,1]
<strong>解释:</strong>因为 nums[0] + nums[1] == 9 ,返回 [0, 1] 。
</pre>

<p><strong>示例 2:</strong></p>

<pre>
<strong>输入:</strong>nums = [3,2,4], target = 6
<strong>输出:</strong>[1,2]
</pre>

<p><strong>示例 3:</strong></p>

<pre>
<strong>输入:</strong>nums = [3,3], target = 6
<strong>输出:</strong>[0,1]
</pre>

<p> </p>

<p><strong>提示:</strong></p>

<ul>
<li><code>2 <= nums.length <= 10<sup>3</sup></code></li>
<li><code>-10<sup>9</sup> <= nums[i] <= 10<sup>9</sup></code></li>
<li><code>-10<sup>9</sup> <= target <= 10<sup>9</sup></code></li>
<li><strong>只会存在一个有效答案</strong></li>
</ul>


## 解法

<!-- 这里可写通用的实现逻辑 -->
Expand Down
36 changes: 29 additions & 7 deletions solution/0000-0099/0001.Two Sum/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,45 @@

## Description

<p>Given an array of integers, return <strong>indices</strong> of the two numbers such that they add up to a specific target.</p>
<p>Given an array of integers <code>nums</code>&nbsp;and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>

<p>You may assume that each input would have <strong><em>exactly</em></strong> one solution, and you may not use the <em>same</em> element twice.</p>
<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> element twice.</p>

<p><strong>Example:</strong></p>
<p>You can return the answer in any order.</p>

<p>&nbsp;</p>
<p><strong>Example 1:</strong></p>

<pre>
<strong>Input:</strong> nums = [2,7,11,15], target = 9
<strong>Output:</strong> [0,1]
<strong>Output:</strong> Because nums[0] + nums[1] == 9, we return [0, 1].
</pre>

Given nums = [2, 7, 11, 15], target = 9,
<p><strong>Example 2:</strong></p>

<pre>
<strong>Input:</strong> nums = [3,2,4], target = 6
<strong>Output:</strong> [1,2]
</pre>

<p><strong>Example 3:</strong></p>

<pre>
<strong>Input:</strong> nums = [3,3], target = 6
<strong>Output:</strong> [0,1]
</pre>

Because nums[<strong>0</strong>] + nums[<strong>1</strong>] = 2 + 7 = 9,
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

return [<strong>0</strong>, <strong>1</strong>].
<ul>
<li><code>2 &lt;= nums.length &lt;= 10<sup>3</sup></code></li>
<li><code>-10<sup>9</sup> &lt;= nums[i] &lt;= 10<sup>9</sup></code></li>
<li><code>-10<sup>9</sup> &lt;= target &lt;= 10<sup>9</sup></code></li>
<li><strong>Only one valid answer exists.</strong></li>
</ul>

</pre>

## Solutions

Expand Down
43 changes: 36 additions & 7 deletions solution/0000-0099/0002.Add Two Numbers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,48 @@
## 题目描述

<!-- 这里写题目描述 -->
<p>给出两个&nbsp;<strong>非空</strong> 的链表用来表示两个非负的整数。其中,它们各自的位数是按照&nbsp;<strong>逆序</strong>&nbsp;的方式存储的,并且它们的每个节点只能存储&nbsp;<strong>一位</strong>&nbsp;数字。</p>

<p>如果,我们将这两个数相加起来,则会返回一个新的链表来表示它们的和。</p>
<p>给你两个 <strong>非空</strong> 的链表,表示两个非负的整数。它们每位数字都是按照 <strong>逆序</strong> 的方式存储的,并且每个节点只能存储 <strong>一位</strong> 数字。</p>

<p>您可以假设除了数字 0 之外,这两个数都不会以 0&nbsp;开头。</p>
<p>请你将两个数相加,并以相同形式返回一个表示和的链表。</p>

<p><strong>示例:</strong></p>
<p>你可以假设除了数字 0 之外,这两个数都不会以 0 开头。</p>

<pre><strong>输入:</strong>(2 -&gt; 4 -&gt; 3) + (5 -&gt; 6 -&gt; 4)
<strong>输出:</strong>7 -&gt; 0 -&gt; 8
<strong>原因:</strong>342 + 465 = 807
<p> </p>

<p><strong>示例 1:</strong></p>
<img alt="" src="https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2021/01/02/addtwonumber1.jpg" style="width: 483px; height: 342px;" />
<pre>
<strong>输入:</strong>l1 = [2,4,3], l2 = [5,6,4]
<strong>输出:</strong>[7,0,8]
<strong>解释:</strong>342 + 465 = 807.
</pre>

<p><strong>示例 2:</strong></p>

<pre>
<strong>输入:</strong>l1 = [0], l2 = [0]
<strong>输出:</strong>[0]
</pre>

<p><strong>示例 3:</strong></p>

<pre>
<strong>输入:</strong>l1 = [9,9,9,9,9,9,9], l2 = [9,9,9,9]
<strong>输出:</strong>[8,9,9,9,0,0,0,1]
</pre>

<p> </p>

<p><strong>提示:</strong></p>

<ul>
<li>每个链表中的节点数在范围 <code>[1, 100]</code> 内</li>
<li><code>0 <= Node.val <= 9</code></li>
<li>题目数据保证列表表示的数字不含前导零</li>
</ul>


## 解法

<!-- 这里可写通用的实现逻辑 -->
Expand Down
33 changes: 27 additions & 6 deletions solution/0000-0099/0002.Add Two Numbers/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,43 @@

## Description

<p>You are given two <b>non-empty</b> linked lists representing two non-negative integers. The digits are stored in <b>reverse order</b> and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.</p>
<p>You are given two <strong>non-empty</strong> linked lists representing two non-negative integers. The digits are stored in <strong>reverse order</strong>, and each of their nodes contains a single digit. Add the two numbers and return the sum&nbsp;as a linked list.</p>

<p>You may assume the two numbers do not contain any leading zero, except the number 0 itself.</p>

<p><b>Example:</b></p>

<p>&nbsp;</p>
<p><strong>Example 1:</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2020/10/02/addtwonumber1.jpg" style="width: 483px; height: 342px;" />
<pre>
<strong>Input:</strong> l1 = [2,4,3], l2 = [5,6,4]
<strong>Output:</strong> [7,0,8]
<strong>Explanation:</strong> 342 + 465 = 807.
</pre>

<b>Input:</b> (2 -&gt; 4 -&gt; 3) + (5 -&gt; 6 -&gt; 4)
<p><strong>Example 2:</strong></p>

<b>Output:</b> 7 -&gt; 0 -&gt; 8
<pre>
<strong>Input:</strong> l1 = [0], l2 = [0]
<strong>Output:</strong> [0]
</pre>

<b>Explanation:</b> 342 + 465 = 807.
<p><strong>Example 3:</strong></p>

<pre>
<strong>Input:</strong> l1 = [9,9,9,9,9,9,9], l2 = [9,9,9,9]
<strong>Output:</strong> [8,9,9,9,0,0,0,1]
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
<li>The number of nodes in each linked list is in the range <code>[1, 100]</code>.</li>
<li><code>0 &lt;= Node.val &lt;= 9</code></li>
<li>It is guaranteed that the list represents a number that does not have leading zeros.</li>
</ul>


## Solutions

<!-- tabs:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,53 @@
## 题目描述

<!-- 这里写题目描述 -->
<p>给定一个字符串,请你找出其中不含有重复字符的&nbsp;<strong>最长子串&nbsp;</strong>的长度。</p>

<p><strong>示例&nbsp;1:</strong></p>
<p>给定一个字符串,请你找出其中不含有重复字符的 <strong>最长子串 </strong>的长度。</p>

<pre><strong>输入: </strong>&quot;abcabcbb&quot;
<p> </p>

<p><strong>示例 1:</strong></p>

<pre>
<strong>输入: </strong>s = "abcabcbb"
<strong>输出: </strong>3
<strong>解释:</strong> 因为无重复字符的最长子串是 <code>&quot;abc&quot;,所以其</code>长度为 3。
<strong>解释:</strong> 因为无重复字符的最长子串是 <code>"abc",所以其</code>长度为 3。
</pre>

<p><strong>示例 2:</strong></p>

<pre><strong>输入: </strong>&quot;bbbbb&quot;
<pre>
<strong>输入: </strong>s = "bbbbb"
<strong>输出: </strong>1
<strong>解释: </strong>因为无重复字符的最长子串是 <code>&quot;b&quot;</code>,所以其长度为 1。
<strong>解释: </strong>因为无重复字符的最长子串是 <code>"b"</code>,所以其长度为 1。
</pre>

<p><strong>示例 3:</strong></p>

<pre><strong>输入: </strong>&quot;pwwkew&quot;
<pre>
<strong>输入: </strong>s = "pwwkew"
<strong>输出: </strong>3
<strong>解释: </strong>因为无重复字符的最长子串是&nbsp;<code>&quot;wke&quot;</code>,所以其长度为 3。
&nbsp; 请注意,你的答案必须是 <strong>子串 </strong>的长度,<code>&quot;pwke&quot;</code>&nbsp;是一个<em>子序列,</em>不是子串。
<strong>解释: </strong>因为无重复字符的最长子串是 <code>"wke"</code>,所以其长度为 3。
  请注意,你的答案必须是 <strong>子串 </strong>的长度,<code>"pwke"</code> 是一个<em>子序列,</em>不是子串。
</pre>

<p><strong>示例 4:</strong></p>

<pre>
<strong>输入: </strong>s = ""
<strong>输出: </strong>0
</pre>

<p> </p>

<p><strong>提示:</strong></p>

<ul>
<li><code>0 <= s.length <= 5 * 10<sup>4</sup></code></li>
<li><code>s</code> 由英文字母、数字、符号和空格组成</li>
</ul>


## 解法

<!-- 这里可写通用的实现逻辑 -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,57 +4,49 @@

## Description

<p>Given a string, find the length of the <b>longest substring</b> without repeating characters.</p>

<div>
<p>Given a string <code>s</code>, find the length of the <b>longest substring</b> without repeating characters.</p>

<p>&nbsp;</p>
<p><strong>Example 1:</strong></p>

<pre>

<strong>Input: </strong><span id="example-input-1-1">&quot;abcabcbb&quot;</span>

<strong>Output: </strong><span id="example-output-1">3

<strong>Explanation:</strong></span> The answer is <code>&quot;abc&quot;</code>, with the length of 3.

<strong>Input:</strong> s = &quot;abcabcbb&quot;
<strong>Output:</strong> 3
<strong>Explanation:</strong> The answer is &quot;abc&quot;, with the length of 3.
</pre>

<div>

<p><strong>Example 2:</strong></p>

<pre>

<strong>Input: </strong><span id="example-input-2-1">&quot;bbbbb&quot;</span>

<strong>Output: </strong><span id="example-output-2">1

</span><span id="example-output-1"><strong>Explanation: </strong>T</span>he answer is <code>&quot;b&quot;</code>, with the length of 1.

<strong>Input:</strong> s = &quot;bbbbb&quot;
<strong>Output:</strong> 1
<strong>Explanation:</strong> The answer is &quot;b&quot;, with the length of 1.
</pre>

<div>

<p><strong>Example 3:</strong></p>

<pre>
<strong>Input:</strong> s = &quot;pwwkew&quot;
<strong>Output:</strong> 3
<strong>Explanation:</strong> The answer is &quot;wke&quot;, with the length of 3.
Notice that the answer must be a substring, &quot;pwke&quot; is a subsequence and not a substring.
</pre>

<strong>Input: </strong><span id="example-input-3-1">&quot;pwwkew&quot;</span>

<strong>Output: </strong><span id="example-output-3">3

</span><span id="example-output-1"><strong>Explanation: </strong></span>The answer is <code>&quot;wke&quot;</code>, with the length of 3.

Note that the answer must be a <b>substring</b>, <code>&quot;pwke&quot;</code> is a <i>subsequence</i> and not a substring.
<p><strong>Example 4:</strong></p>

<pre>
<strong>Input:</strong> s = &quot;&quot;
<strong>Output:</strong> 0
</pre>

</div>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

</div>
<ul>
<li><code>0 &lt;= s.length &lt;= 5 * 10<sup>4</sup></code></li>
<li><code>s</code> consists of English letters, digits, symbols and spaces.</li>
</ul>

</div>

## Solutions

Expand Down
Loading

0 comments on commit 44dc9b6

Please sign in to comment.