You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: solution/0000-0099/0003.Longest Substring Without Repeating Characters/README_EN.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,7 @@ tags:
18
18
19
19
<!-- description:start -->
20
20
21
-
<p>Given a string <code>s</code>, find the length of the <strong>longest</strong> <spandata-keyword="substring-nonempty"><strong>substring</strong></span> without repeating characters.</p>
21
+
<p>Given a string <code>s</code>, find the length of the <strong>longest</strong> <spandata-keyword="substring-nonempty"><strong>substring</strong></span> without duplicate characters.</p>
Copy file name to clipboardexpand all lines: solution/0700-0799/0763.Partition Labels/README_EN.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ tags:
19
19
20
20
<!-- description:start -->
21
21
22
-
<p>You are given a string <code>s</code>. We want to partition the string into as many parts as possible so that each letter appears in at most one part.</p>
22
+
<p>You are given a string <code>s</code>. We want to partition the string into as many parts as possible so that each letter appears in at most one part. For example, the string <code>"ababcc"</code> can be partitioned into <code>["abab", "cc"]</code>, but partitions such as <code>["aba", "bcc"]</code> or <code>["ab", "ab", "cc"]</code> are invalid.</p>
23
23
24
24
<p>Note that the partition is done so that after concatenating all the parts in order, the resultant string should be <code>s</code>.</p>
Copy file name to clipboardexpand all lines: solution/1200-1299/1261.Find Elements in a Contaminated Binary Tree/README_EN.md
+6-2
Original file line number
Diff line number
Diff line change
@@ -27,8 +27,12 @@ tags:
27
27
28
28
<ol>
29
29
<li><code>root.val == 0</code></li>
30
-
<li>If <code>treeNode.val == x</code> and <code>treeNode.left != null</code>, then <code>treeNode.left.val == 2 * x + 1</code></li>
31
-
<li>If <code>treeNode.val == x</code> and <code>treeNode.right != null</code>, then <code>treeNode.right.val == 2 * x + 2</code></li>
30
+
<li>For any <code>treeNode</code>:
31
+
<ol type="a">
32
+
<li>If <code>treeNode.val</code> has a value <code>x</code> and <code>treeNode.left != null</code>, then <code>treeNode.left.val == 2 * x + 1</code></li>
33
+
<li>If <code>treeNode.val</code> has a value <code>x</code> and <code>treeNode.right != null</code>, then <code>treeNode.right.val == 2 * x + 2</code></li>
34
+
</ol>
35
+
</li>
32
36
</ol>
33
37
34
38
<p>Now the binary tree is contaminated, which means all <code>treeNode.val</code> have been changed to <code>-1</code>.</p>
Copy file name to clipboardexpand all lines: solution/1300-1399/1352.Product of the Last K Numbers/README_EN.md
+4-1
Original file line number
Diff line number
Diff line change
@@ -56,7 +56,7 @@ productOfNumbers.getProduct(2); // return 20. The product of the last 2 numbers
56
56
productOfNumbers.getProduct(3); // return 40. The product of the last 3 numbers is 2 * 5 * 4 = 40
57
57
productOfNumbers.getProduct(4); // return 0. The product of the last 4 numbers is 0 * 2 * 5 * 4 = 0
58
58
productOfNumbers.add(8); // [3,0,2,5,4,8]
59
-
productOfNumbers.getProduct(2); // return 32. The product of the last 2 numbers is 4 * 8 = 32
59
+
productOfNumbers.getProduct(2); // return 32. The product of the last 2 numbers is 4 * 8 = 32
60
60
</pre>
61
61
62
62
<p> </p>
@@ -69,6 +69,9 @@ productOfNumbers.getProduct(2); // return 32. The product of the last 2 numbers
69
69
<li>The product of the stream at any point in time will fit in a <strong>32-bit</strong> integer.</li>
70
70
</ul>
71
71
72
+
<p> </p>
73
+
<strong>Follow-up: </strong>Can you implement <strong>both</strong> <code>GetProduct</code> and <code>Add</code> to work in <code>O(1)</code> time complexity instead of <code>O(k)</code> time complexity?
Copy file name to clipboardexpand all lines: solution/1400-1499/1408.String Matching in an Array/README_EN.md
+1-3
Original file line number
Diff line number
Diff line change
@@ -20,9 +20,7 @@ tags:
20
20
21
21
<!-- description:start -->
22
22
23
-
<p>Given an array of string <code>words</code>, return <em>all strings in </em><code>words</code><em> that is a <strong>substring</strong> of another word</em>. You can return the answer in <strong>any order</strong>.</p>
24
-
25
-
<p>A <strong>substring</strong> is a contiguous sequence of characters within a string</p>
23
+
<p>Given an array of string <code>words</code>, return all strings in<em> </em><code>words</code><em> </em>that are a <spandata-keyword="substring-nonempty">substring</span> of another word. You can return the answer in <strong>any order</strong>.</p>
Copy file name to clipboardexpand all lines: solution/1700-1799/1752.Check if Array Is Sorted and Rotated/README_EN.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,7 @@ tags:
22
22
23
23
<p>There may be <strong>duplicates</strong> in the original array.</p>
24
24
25
-
<p><strong>Note:</strong> An array <code>A</code> rotated by <code>x</code> positions results in an array <code>B</code> of the same length such that <code>A[i] == B[(i+x) % A.length]</code>, where <code>%</code> is the modulo operation.</p>
25
+
<p><strong>Note:</strong> An array <code>A</code> rotated by <code>x</code> positions results in an array <code>B</code> of the same length such that <code>B[i] == A[(i+x) % A.length]</code> for every valid index <code>i</code>.</p>
Copy file name to clipboardexpand all lines: solution/1800-1899/1800.Maximum Ascending Subarray Sum/README_EN.md
+1-3
Original file line number
Diff line number
Diff line change
@@ -18,12 +18,10 @@ tags:
18
18
19
19
<!-- description:start -->
20
20
21
-
<p>Given an array of positive integers <code>nums</code>, return the <em>maximum possible sum of an <strong>ascending</strong> subarray in </em><code>nums</code>.</p>
21
+
<p>Given an array of positive integers <code>nums</code>, return the <strong>maximum</strong> possible sum of an <spandata-keyword="strictly-increasing-array">strictly increasing subarray</span> in<em> </em><code>nums</code>.</p>
22
22
23
23
<p>A subarray is defined as a contiguous sequence of numbers in an array.</p>
24
24
25
-
<p>A subarray <code>[nums<sub>l</sub>, nums<sub>l+1</sub>, ..., nums<sub>r-1</sub>, nums<sub>r</sub>]</code> is <strong>ascending</strong> if for all <code>i</code> where <code>l <= i < r</code>, <code>nums<sub>i </sub> < nums<sub>i+1</sub></code>. Note that a subarray of size <code>1</code> is <strong>ascending</strong>.</p>
Copy file name to clipboardexpand all lines: solution/1800-1899/1852.Distinct Numbers in Each Subarray/README_EN.md
+13-35
Original file line number
Diff line number
Diff line change
@@ -18,64 +18,42 @@ tags:
18
18
19
19
<!-- description:start -->
20
20
21
-
<p>Given an integer array <code>nums</code> and an integer <code>k</code>, you are asked to construct the array <code>ans</code> of size <code>n-k+1</code> where <code>ans[i]</code> is the number of <strong>distinct</strong> numbers in the subarray <code>nums[i:i+k-1] = [nums[i], nums[i+1], ..., nums[i+k-1]]</code>.</p>
21
+
<p>You are given an integer array <code>nums</code> of length <code>n</code> and an integer <code>k</code>. Your task is to find the number of <strong>distinct</strong> elements in <strong>every</strong> subarray of size <code>k</code> within <code>nums</code>.</p>
<p>Return an array <code>ans</code> such that <code>ans[i]</code> is the count of distinct elements in <code>nums[i..(i + k - 1)]</code> for each index <code>0 <= i < n - k</code>.</p>
24
24
25
25
<p> </p>
26
-
27
26
<p><strongclass="example">Example 1:</strong></p>
28
27
29
28
<pre>
30
-
31
29
<strong>Input:</strong> nums = [1,2,3,2,2,1,3], k = 3
32
-
33
30
<strong>Output:</strong> [3,2,2,2,3]
34
-
35
31
<strong>Explanation: </strong>The number of distinct elements in each subarray goes as follows:
36
-
37
-
- nums[0:2] = [1,2,3] so ans[0] = 3
38
-
39
-
- nums[1:3] = [2,3,2] so ans[1] = 2
40
-
41
-
- nums[2:4] = [3,2,2] so ans[2] = 2
42
-
43
-
- nums[3:5] = [2,2,1] so ans[3] = 2
44
-
45
-
- nums[4:6] = [2,1,3] so ans[4] = 3
46
-
32
+
- nums[0..2] = [1,2,3] so ans[0] = 3
33
+
- nums[1..3] = [2,3,2] so ans[1] = 2
34
+
- nums[2..4] = [3,2,2] so ans[2] = 2
35
+
- nums[3..5] = [2,2,1] so ans[3] = 2
36
+
- nums[4..6] = [2,1,3] so ans[4] = 3
47
37
</pre>
48
38
49
39
<p><strongclass="example">Example 2:</strong></p>
50
40
51
41
<pre>
52
-
53
42
<strong>Input:</strong> nums = [1,1,1,1,2,3,4], k = 4
54
-
55
43
<strong>Output:</strong> [1,2,3,4]
56
-
57
44
<strong>Explanation: </strong>The number of distinct elements in each subarray goes as follows:
58
-
59
-
- nums[0:3] = [1,1,1,1] so ans[0] = 1
60
-
61
-
- nums[1:4] = [1,1,1,2] so ans[1] = 2
62
-
63
-
- nums[2:5] = [1,1,2,3] so ans[2] = 3
64
-
65
-
- nums[3:6] = [1,2,3,4] so ans[3] = 4
66
-
45
+
- nums[0..3] = [1,1,1,1] so ans[0] = 1
46
+
- nums[1..4] = [1,1,1,2] so ans[1] = 2
47
+
- nums[2..5] = [1,1,2,3] so ans[2] = 3
48
+
- nums[3..6] = [1,2,3,4] so ans[3] = 4
67
49
</pre>
68
50
69
51
<p> </p>
70
-
71
52
<p><strong>Constraints:</strong></p>
72
53
73
54
<ul>
74
-
75
-
<li><code>1 <= k <= nums.length <= 10<sup>5</sup></code></li>
0 commit comments