Skip to content

Commit d50023a

Browse files
author
Shuo
committed
A: new
1 parent cfe4d20 commit d50023a

File tree

97 files changed

+1872
-980
lines changed

Some content is hidden

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

97 files changed

+1872
-980
lines changed

Diff for: README.md

+16
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,22 @@ LeetCode Problems' Solutions
7878

7979
| # | Title | Solution | Difficulty |
8080
| :-: | - | - | :-: |
81+
| <span id="1819">1819</span> | [Number of Different Subsequences GCDs](https://leetcode.com/problems/number-of-different-subsequences-gcds "序列中不同最大公约数的数目") | [Go](problems/number-of-different-subsequences-gcds) | Hard |
82+
| <span id="1818">1818</span> | [Minimum Absolute Sum Difference](https://leetcode.com/problems/minimum-absolute-sum-difference "绝对差值和") | [Go](problems/minimum-absolute-sum-difference) | Medium |
83+
| <span id="1817">1817</span> | [Finding the Users Active Minutes](https://leetcode.com/problems/finding-the-users-active-minutes "查找用户活跃分钟数") | [Go](problems/finding-the-users-active-minutes) | Medium |
84+
| <span id="1816">1816</span> | [Truncate Sentence](https://leetcode.com/problems/truncate-sentence "截断句子") | [Go](problems/truncate-sentence) | Easy |
85+
| <span id="1815">1815</span> | [Maximum Number of Groups Getting Fresh Donuts](https://leetcode.com/problems/maximum-number-of-groups-getting-fresh-donuts "得到新鲜甜甜圈的最多组数") | [Go](problems/maximum-number-of-groups-getting-fresh-donuts) | Hard |
86+
| <span id="1814">1814</span> | [Count Nice Pairs in an Array](https://leetcode.com/problems/count-nice-pairs-in-an-array "统计一个数组中好对子的数目") | [Go](problems/count-nice-pairs-in-an-array) | Medium |
87+
| <span id="1813">1813</span> | [Sentence Similarity III](https://leetcode.com/problems/sentence-similarity-iii "句子相似性 III") | [Go](problems/sentence-similarity-iii) | Medium |
88+
| <span id="1812">1812</span> | [Determine Color of a Chessboard Square](https://leetcode.com/problems/determine-color-of-a-chessboard-square "判断国际象棋棋盘中一个格子的颜色") | [Go](problems/determine-color-of-a-chessboard-square) | Easy |
89+
| <span id="1811">1811</span> | [Find Interview Candidates](https://leetcode.com/problems/find-interview-candidates) 🔒 | [MySQL](problems/find-interview-candidates) | Medium |
90+
| <span id="1810">1810</span> | [Minimum Path Cost in a Hidden Grid](https://leetcode.com/problems/minimum-path-cost-in-a-hidden-grid) 🔒 | [Go](problems/minimum-path-cost-in-a-hidden-grid) | Medium |
91+
| <span id="1809">1809</span> | [Ad-Free Sessions](https://leetcode.com/problems/ad-free-sessions) 🔒 | [MySQL](problems/ad-free-sessions) | Easy |
92+
| <span id="1808">1808</span> | [Maximize Number of Nice Divisors](https://leetcode.com/problems/maximize-number-of-nice-divisors "好因子的最大数目") | [Go](problems/maximize-number-of-nice-divisors) | Hard |
93+
| <span id="1807">1807</span> | [Evaluate the Bracket Pairs of a String](https://leetcode.com/problems/evaluate-the-bracket-pairs-of-a-string "替换字符串中的括号内容") | [Go](problems/evaluate-the-bracket-pairs-of-a-string) | Medium |
94+
| <span id="1806">1806</span> | [Minimum Number of Operations to Reinitialize a Permutation](https://leetcode.com/problems/minimum-number-of-operations-to-reinitialize-a-permutation "还原排列的最少操作步数") | [Go](problems/minimum-number-of-operations-to-reinitialize-a-permutation) | Medium |
95+
| <span id="1805">1805</span> | [Number of Different Integers in a String](https://leetcode.com/problems/number-of-different-integers-in-a-string "字符串中不同整数的数目") | [Go](problems/number-of-different-integers-in-a-string) | Easy |
96+
| <span id="1804">1804</span> | [Implement Trie II (Prefix Tree)](https://leetcode.com/problems/implement-trie-ii-prefix-tree) 🔒 | [Go](problems/implement-trie-ii-prefix-tree) | Medium |
8197
| <span id="1803">1803</span> | [Count Pairs With XOR in a Range](https://leetcode.com/problems/count-pairs-with-xor-in-a-range "统计异或值在范围内的数对有多少") | [Go](problems/count-pairs-with-xor-in-a-range) | Hard |
8298
| <span id="1802">1802</span> | [Maximum Value at a Given Index in a Bounded Array](https://leetcode.com/problems/maximum-value-at-a-given-index-in-a-bounded-array "有界数组中指定下标处的最大值") | [Go](problems/maximum-value-at-a-given-index-in-a-bounded-array) | Medium |
8399
| <span id="1801">1801</span> | [Number of Orders in the Backlog](https://leetcode.com/problems/number-of-orders-in-the-backlog "积压订单中的订单总数") | [Go](problems/number-of-orders-in-the-backlog) | Medium |

Diff for: problems/132-pattern/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
[Next >](../circular-array-loop "Circular Array Loop")
1111

12-
## [456. 132 Pattern (Medium)](https://leetcode.com/problems/132-pattern "132模式")
12+
## [456. 132 Pattern (Medium)](https://leetcode.com/problems/132-pattern "132 模式")
1313

1414
<p>Given an array&nbsp;of <code>n</code> integers <code>nums</code>, a <strong>132 pattern</strong> is a subsequence of three integers <code>nums[i]</code>, <code>nums[j]</code> and <code>nums[k]</code> such that <code>i &lt; j &lt; k</code> and <code>nums[i] &lt; nums[k] &lt; nums[j]</code>.</p>
1515

Diff for: problems/3sum/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
## [15. 3Sum (Medium)](https://leetcode.com/problems/3sum "三数之和")
1313

14-
<p>Given an array <code>nums</code> of <em>n</em> integers, are there elements <em>a</em>, <em>b</em>, <em>c</em> in <code>nums</code> such that <em>a</em> + <em>b</em> + <em>c</em> = 0? Find all unique triplets in the array which gives the sum of zero.</p>
14+
<p>Given an integer array nums, return all the triplets <code>[nums[i], nums[j], nums[k]]</code> such that <code>i != j</code>, <code>i != k</code>, and <code>j != k</code>, and <code>nums[i] + nums[j] + nums[k] == 0</code>.</p>
1515

1616
<p>Notice that the solution set must not contain duplicate triplets.</p>
1717

Diff for: problems/ad-free-sessions/README.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
2+
<!--+----------------------------------------------------------------------+-->
3+
<!--|@author openset <[email protected]> |-->
4+
<!--|@link https://github.com/openset |-->
5+
<!--|@home https://github.com/openset/leetcode |-->
6+
<!--+----------------------------------------------------------------------+-->
7+
8+
[< Previous](../maximize-number-of-nice-divisors "Maximize Number of Nice Divisors")
9+
                
10+
[Next >](../minimum-path-cost-in-a-hidden-grid "Minimum Path Cost in a Hidden Grid")
11+
12+
## [1809. Ad-Free Sessions (Easy)](https://leetcode.com/problems/ad-free-sessions "")
13+
14+

Diff for: problems/ad-free-sessions/mysql_schemas.sql

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Create table If Not Exists Playback(session_id int,customer_id int,start_time int,end_time int);
2+
Create table If Not Exists Ads (ad_id int, customer_id int, timestamp int);
3+
Truncate table Playback;
4+
insert into Playback (session_id, customer_id, start_time, end_time) values ('1', '1', '1', '5');
5+
insert into Playback (session_id, customer_id, start_time, end_time) values ('2', '1', '15', '23');
6+
insert into Playback (session_id, customer_id, start_time, end_time) values ('3', '2', '10', '12');
7+
insert into Playback (session_id, customer_id, start_time, end_time) values ('4', '2', '17', '28');
8+
insert into Playback (session_id, customer_id, start_time, end_time) values ('5', '2', '2', '8');
9+
Truncate table Ads;
10+
insert into Ads (ad_id, customer_id, timestamp) values ('1', '1', '5');
11+
insert into Ads (ad_id, customer_id, timestamp) values ('2', '2', '17');
12+
insert into Ads (ad_id, customer_id, timestamp) values ('3', '2', '20');

Diff for: problems/add-strings/README.md

+35-10
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,41 @@
1111

1212
## [415. Add Strings (Easy)](https://leetcode.com/problems/add-strings "字符串相加")
1313

14-
<p>Given two non-negative integers <code>num1</code> and <code>num2</code> represented as string, return the sum of <code>num1</code> and <code>num2</code>.</p>
15-
16-
<p><b>Note:</b>
17-
<ol>
18-
<li>The length of both <code>num1</code> and <code>num2</code> is < 5100.</li>
19-
<li>Both <code>num1</code> and <code>num2</code> contains only digits <code>0-9</code>.</li>
20-
<li>Both <code>num1</code> and <code>num2</code> does not contain any leading zero.</li>
21-
<li>You <b>must not use any built-in BigInteger library</b> or <b>convert the inputs to integer</b> directly.</li>
22-
</ol>
23-
</p>
14+
<p>Given two non-negative integers, <code>num1</code> and <code>num2</code> represented as string, return <em>the sum of</em> <code>num1</code> <em>and</em> <code>num2</code> <em>as a string</em>.</p>
15+
16+
<p>&nbsp;</p>
17+
<p><strong>Example 1:</strong></p>
18+
19+
<pre>
20+
<strong>Input:</strong> num1 = &quot;11&quot;, num2 = &quot;123&quot;
21+
<strong>Output:</strong> &quot;134&quot;
22+
</pre>
23+
24+
<p><strong>Example 2:</strong></p>
25+
26+
<pre>
27+
<strong>Input:</strong> num1 = &quot;456&quot;, num2 = &quot;77&quot;
28+
<strong>Output:</strong> &quot;533&quot;
29+
</pre>
30+
31+
<p><strong>Example 3:</strong></p>
32+
33+
<pre>
34+
<strong>Input:</strong> num1 = &quot;0&quot;, num2 = &quot;0&quot;
35+
<strong>Output:</strong> &quot;0&quot;
36+
</pre>
37+
38+
<p>&nbsp;</p>
39+
<p><strong>Constraints:</strong></p>
40+
41+
<ul>
42+
<li><code>1 &lt;= num1.length, num2.length &lt;= 10<sup>4</sup></code></li>
43+
<li><code>num1</code> and <code>num2</code> consist of only digits.</li>
44+
<li><code>num1</code> and <code>num2</code> don&#39;t have any leading zeros except for the zero itself.</li>
45+
</ul>
46+
47+
<p>&nbsp;</p>
48+
<p><strong>Follow up:</strong> Could you solve it without using any built-in <code>BigInteger</code> library or converting the inputs to integer directly?</p>
2449

2550
### Related Topics
2651
[[String](../../tag/string/README.md)]

Diff for: problems/add-to-array-form-of-integer/README.md

+26-35
Original file line numberDiff line numberDiff line change
@@ -11,65 +11,56 @@
1111

1212
## [989. Add to Array-Form of Integer (Easy)](https://leetcode.com/problems/add-to-array-form-of-integer "数组形式的整数加法")
1313

14-
<p>For a non-negative integer <code>X</code>, the&nbsp;<em>array-form of <code>X</code></em>&nbsp;is an array of its digits in left to right order.&nbsp; For example, if <code>X = 1231</code>, then the array form is&nbsp;<code>[1,2,3,1]</code>.</p>
14+
<p>The <strong>array-form</strong> of an integer <code>num</code> is an array representing its digits in left to right order.</p>
1515

16-
<p>Given the array-form <code>A</code> of a non-negative&nbsp;integer <code>X</code>, return the array-form of the integer <code>X+K</code>.</p>
16+
<ul>
17+
<li>For example, for <code>num = 1321</code>, the array form is <code>[1,3,2,1]</code>.</li>
18+
</ul>
1719

18-
<p>&nbsp;</p>
19-
20-
<ol>
21-
</ol>
20+
<p>Given <code>num</code>, the <strong>array-form</strong> of an integer, and an integer <code>k</code>, return <em>the <strong>array-form</strong> of the integer</em> <code>num + k</code>.</p>
2221

23-
<div>
22+
<p>&nbsp;</p>
2423
<p><strong>Example 1:</strong></p>
2524

2625
<pre>
27-
<strong>Input: </strong>A = <span id="example-input-1-1">[1,2,0,0]</span>, K = 34
28-
<strong>Output: </strong><span id="example-output-1">[1,2,3,4]</span>
29-
<strong>Explanation: </strong>1200 + 34 = 1234
26+
<strong>Input:</strong> num = [1,2,0,0], k = 34
27+
<strong>Output:</strong> [1,2,3,4]
28+
<strong>Explanation:</strong> 1200 + 34 = 1234
3029
</pre>
3130

32-
<div>
3331
<p><strong>Example 2:</strong></p>
3432

3533
<pre>
36-
<strong>Input: </strong>A = <span id="example-input-2-1">[2,7,4]</span>, K = <span id="example-input-2-2">181</span>
37-
<strong>Output: </strong><span id="example-output-2">[4,5,5]</span>
38-
<strong>Explanation: </strong>274 + 181 = 455
34+
<strong>Input:</strong> num = [2,7,4], k = 181
35+
<strong>Output:</strong> [4,5,5]
36+
<strong>Explanation:</strong> 274 + 181 = 455
3937
</pre>
4038

41-
<div>
4239
<p><strong>Example 3:</strong></p>
4340

4441
<pre>
45-
<strong>Input: </strong>A = <span id="example-input-3-1">[2,1,5]</span>, K = <span id="example-input-3-2">806</span>
46-
<strong>Output: </strong><span id="example-output-3">[1,0,2,1]</span>
47-
<strong>Explanation: </strong>215 + 806 = 1021
42+
<strong>Input:</strong> num = [2,1,5], k = 806
43+
<strong>Output:</strong> [1,0,2,1]
44+
<strong>Explanation:</strong> 215 + 806 = 1021
4845
</pre>
4946

50-
<div>
5147
<p><strong>Example 4:</strong></p>
5248

5349
<pre>
54-
<strong>Input: </strong>A = <span id="example-input-4-1">[9,9,9,9,9,9,9,9,9,9]</span>, K = <span id="example-input-4-2">1</span>
55-
<strong>Output: </strong><span id="example-output-4">[1,0,0,0,0,0,0,0,0,0,0]</span>
56-
<strong>Explanation: </strong>9999999999 + 1 = 10000000000
50+
<strong>Input:</strong> num = [9,9,9,9,9,9,9,9,9,9], k = 1
51+
<strong>Output:</strong> [1,0,0,0,0,0,0,0,0,0,0]
52+
<strong>Explanation:</strong> 9999999999 + 1 = 10000000000
5753
</pre>
5854

5955
<p>&nbsp;</p>
60-
61-
<p><strong>Note:</strong></p>
62-
63-
<ol>
64-
<li><code>1 &lt;= A.length &lt;= 10000</code></li>
65-
<li><code>0 &lt;= A[i] &lt;= 9</code></li>
66-
<li><code>0 &lt;= K &lt;= 10000</code></li>
67-
<li>If <code>A.length &gt; 1</code>, then <code>A[0] != 0</code></li>
68-
</ol>
69-
</div>
70-
</div>
71-
</div>
72-
</div>
56+
<p><strong>Constraints:</strong></p>
57+
58+
<ul>
59+
<li><code>1 &lt;= num.length &lt;= 10<sup>4</sup></code></li>
60+
<li><code>0 &lt;= num[i] &lt;= 9</code></li>
61+
<li><code>num</code>&nbsp;does not contain any leading zeros except for the zero itself.</li>
62+
<li><code>1 &lt;= k &lt;= 10<sup>4</sup></code></li>
63+
</ul>
7364

7465
### Related Topics
7566
[[Array](../../tag/array/README.md)]

Diff for: problems/candy/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ The third child gets 1 candy because it satisfies the above two conditions.
4646
<ul>
4747
<li><code>n == ratings.length</code></li>
4848
<li><code>1 &lt;= n &lt;= 2 * 10<sup>4</sup></code></li>
49-
<li><code>1 &lt;= ratings[i] &lt;= 2 * 10<sup>4</sup></code></li>
49+
<li><code>0 &lt;= ratings[i] &lt;= 2 * 10<sup>4</sup></code></li>
5050
</ul>
5151

5252
### Related Topics

Diff for: problems/combinations/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
## [77. Combinations (Medium)](https://leetcode.com/problems/combinations "组合")
1313

14-
<p>Given two integers <em>n</em> and <em>k</em>, return all possible combinations of <em>k</em> numbers out of 1 ... <em>n</em>.</p>
14+
<p>Given two integers <code>n</code> and <code>k</code>, return <em>all possible combinations of</em> <code>k</code> <em>numbers out of the range</em> <code>[1, n]</code>.</p>
1515

1616
<p>You may return the answer in <strong>any order</strong>.</p>
1717

Diff for: problems/continuous-subarray-sum/README.md

+22-11
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,43 @@
1111

1212
## [523. Continuous Subarray Sum (Medium)](https://leetcode.com/problems/continuous-subarray-sum "连续的子数组和")
1313

14-
<p>Given a list of <b>non-negative</b> numbers and a target <b>integer</b> k, write a function to check if the array has a continuous subarray of size at least 2 that sums up to a multiple of <b>k</b>, that is, sums up to n*k where n is also an <b>integer</b>.</p>
14+
<p>Given an integer array <code>nums</code> and an integer <code>k</code>, return <code>true</code> <em>if </em><code>nums</code><em> has a continuous subarray of size <strong>at least two</strong> whose elements sum up to a multiple of</em> <code>k</code><em>, or </em><code>false</code><em> otherwise</em>.</p>
15+
16+
<p>An integer <code>x</code> is a multiple of <code>k</code> if there exists an integer <code>n</code> such that <code>x = n * k</code>. <code>0</code> is <strong>always</strong> a multiple of <code>k</code>.</p>
1517

1618
<p>&nbsp;</p>
19+
<p><strong>Example 1:</strong></p>
20+
21+
<pre>
22+
<strong>Input:</strong> nums = [23,<u>2,4</u>,6,7], k = 6
23+
<strong>Output:</strong> true
24+
<strong>Explanation:</strong> [2, 4] is a continuous subarray of size 2 whose elements sum up to 6.
25+
</pre>
1726

18-
<p><b>Example 1:</b></p>
27+
<p><strong>Example 2:</strong></p>
1928

2029
<pre>
21-
<b>Input:</b> [23, 2, 4, 6, 7], k=6
22-
<b>Output:</b> True
23-
<b>Explanation:</b> Because [2, 4] is a continuous subarray of size 2 and sums up to 6.
30+
<strong>Input:</strong> nums = [<u>23,2,6,4,7</u>], k = 6
31+
<strong>Output:</strong> true
32+
<strong>Explanation:</strong> [23, 2, 6, 4, 7] is an continuous subarray of size 5 whose elements sum up to 42.
33+
42 is a multiple of 6 because 42 = 7 * 6 and 7 is an integer.
2434
</pre>
2535

26-
<p><b>Example 2:</b></p>
36+
<p><strong>Example 3:</strong></p>
2737

2838
<pre>
29-
<b>Input:</b> [23, 2, 6, 4, 7], k=6
30-
<b>Output:</b> True
31-
<b>Explanation:</b> Because [23, 2, 6, 4, 7] is an continuous subarray of size 5 and sums up to 42.
39+
<strong>Input:</strong> nums = [23,2,6,4,7], k = 13
40+
<strong>Output:</strong> false
3241
</pre>
3342

3443
<p>&nbsp;</p>
3544
<p><strong>Constraints:</strong></p>
3645

3746
<ul>
38-
<li>The length of the array won&#39;t exceed 10,000.</li>
39-
<li>You may assume the sum of all the numbers is in the range of a signed 32-bit integer.</li>
47+
<li><code>1 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
48+
<li><code>0 &lt;= nums[i] &lt;= 10<sup>9</sup></code></li>
49+
<li><code>0 &lt;= sum(nums[i]) &lt;= 2<sup>31</sup> - 1</code></li>
50+
<li><code>1 &lt;= k &lt;= 2<sup>31</sup> - 1</code></li>
4051
</ul>
4152

4253
### Related Topics

Diff for: problems/count-nice-pairs-in-an-array/README.md

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<!--|This file generated by command(leetcode description); DO NOT EDIT. |-->
2+
<!--+----------------------------------------------------------------------+-->
3+
<!--|@author openset <[email protected]> |-->
4+
<!--|@link https://github.com/openset |-->
5+
<!--|@home https://github.com/openset/leetcode |-->
6+
<!--+----------------------------------------------------------------------+-->
7+
8+
[< Previous](../sentence-similarity-iii "Sentence Similarity III")
9+
                
10+
[Next >](../maximum-number-of-groups-getting-fresh-donuts "Maximum Number of Groups Getting Fresh Donuts")
11+
12+
## [1814. Count Nice Pairs in an Array (Medium)](https://leetcode.com/problems/count-nice-pairs-in-an-array "统计一个数组中好对子的数目")
13+
14+
<p>You are given an array <code>nums</code> that consists of non-negative integers. Let us define <code>rev(x)</code> as the reverse of the non-negative integer <code>x</code>. For example, <code>rev(123) = 321</code>, and <code>rev(120) = 21</code>. A pair of indices <code>(i, j)</code> is <strong>nice</strong> if it satisfies all of the following conditions:</p>
15+
16+
<ul>
17+
<li><code>0 &lt;= i &lt; j &lt; nums.length</code></li>
18+
<li><code>nums[i] + rev(nums[j]) == nums[j] + rev(nums[i])</code></li>
19+
</ul>
20+
21+
<p>Return <em>the number of nice pairs of indices</em>. Since that number can be too large, return it <strong>modulo</strong> <code>10<sup>9</sup> + 7</code>.</p>
22+
23+
<p>&nbsp;</p>
24+
<p><strong>Example 1:</strong></p>
25+
26+
<pre>
27+
<strong>Input:</strong> nums = [42,11,1,97]
28+
<strong>Output:</strong> 2
29+
<strong>Explanation:</strong> The two pairs are:
30+
- (0,3) : 42 + rev(97) = 42 + 79 = 121, 97 + rev(42) = 97 + 24 = 121.
31+
- (1,2) : 11 + rev(1) = 11 + 1 = 12, 1 + rev(11) = 1 + 11 = 12.
32+
</pre>
33+
34+
<p><strong>Example 2:</strong></p>
35+
36+
<pre>
37+
<strong>Input:</strong> nums = [13,10,35,24,76]
38+
<strong>Output:</strong> 4
39+
</pre>
40+
41+
<p>&nbsp;</p>
42+
<p><strong>Constraints:</strong></p>
43+
44+
<ul>
45+
<li><code>1 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
46+
<li><code>0 &lt;= nums[i] &lt;= 10<sup>9</sup></code></li>
47+
</ul>
48+
49+
### Related Topics
50+
[[Array](../../tag/array/README.md)]
51+
[[Hash Table](../../tag/hash-table/README.md)]
52+
53+
### Hints
54+
<details>
55+
<summary>Hint 1</summary>
56+
The condition can be rearranged to (nums[i] - rev(nums[i])) == (nums[j] - rev(nums[j])).
57+
</details>
58+
59+
<details>
60+
<summary>Hint 2</summary>
61+
Transform each nums[i] into (nums[i] - rev(nums[i])). Then, count the number of (i, j) pairs that have equal values.
62+
</details>
63+
64+
<details>
65+
<summary>Hint 3</summary>
66+
Keep a map storing the frequencies of values that you have seen so far. For each i, check if nums[i] is in the map. If it is, then add that count to the overall count. Then, increment the frequency of nums[i].
67+
</details>

0 commit comments

Comments
 (0)