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: README.md
+11-5Lines changed: 11 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -70,11 +70,17 @@ LeetCode Problems' Solutions
70
70
71
71
| # | Title | Solution | Difficulty |
72
72
| :-: | - | - | :-: |
73
+
| <spanid="1553">1553</span> |[Minimum Number of Days to Eat N Oranges](https://leetcode.com/problems/minimum-number-of-days-to-eat-n-oranges"吃掉 N 个橘子的最少天数")|[Go](problems/minimum-number-of-days-to-eat-n-oranges)| Hard |
74
+
| <spanid="1552">1552</span> |[Magnetic Force Between Two Balls](https://leetcode.com/problems/magnetic-force-between-two-balls"两球之间的磁力")|[Go](problems/magnetic-force-between-two-balls)| Medium |
75
+
| <spanid="1551">1551</span> |[Minimum Operations to Make Array Equal](https://leetcode.com/problems/minimum-operations-to-make-array-equal"使数组中所有元素相等的最小操作数")|[Go](problems/minimum-operations-to-make-array-equal)| Medium |
| <spanid="1549">1549</span> |[The Most Recent Orders for Each Product](https://leetcode.com/problems/the-most-recent-orders-for-each-product) 🔒 |[MySQL](problems/the-most-recent-orders-for-each-product)| Medium |
78
+
| <spanid="1548">1548</span> |[The Most Similar Path in a Graph](https://leetcode.com/problems/the-most-similar-path-in-a-graph) 🔒 |[Go](problems/the-most-similar-path-in-a-graph)| Hard |
73
79
| <spanid="1547">1547</span> |[Minimum Cost to Cut a Stick](https://leetcode.com/problems/minimum-cost-to-cut-a-stick"切棍子的最小成本")|[Go](problems/minimum-cost-to-cut-a-stick)| Hard |
74
80
| <spanid="1546">1546</span> |[Maximum Number of Non-Overlapping Subarrays With Sum Equals Target](https://leetcode.com/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target"和为目标值的最大数目不重叠非空子数组数目")|[Go](problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target)| Medium |
75
81
| <spanid="1545">1545</span> |[Find Kth Bit in Nth Binary String](https://leetcode.com/problems/find-kth-bit-in-nth-binary-string"找出第 N 个二进制字符串中的第 K 位")|[Go](problems/find-kth-bit-in-nth-binary-string)| Medium |
76
82
| <spanid="1544">1544</span> |[Make The String Great](https://leetcode.com/problems/make-the-string-great"整理字符串")|[Go](problems/make-the-string-great)| Easy |
77
-
| <spanid="1543">1543</span> |[Fix Product Name Format](https://leetcode.com/problems/fix-product-name-format) 🔒 |[MySQL](problems/fix-product-name-format)| Easy |
83
+
| <spanid="1543">1543</span> |[Fix Product Name Format](https://leetcode.com/problems/fix-product-name-format"产品名称格式修复") 🔒 |[MySQL](problems/fix-product-name-format)| Easy |
78
84
| <spanid="1542">1542</span> |[Find Longest Awesome Substring](https://leetcode.com/problems/find-longest-awesome-substring"找出最长的超赞子字符串")|[Go](problems/find-longest-awesome-substring)| Hard |
79
85
| <spanid="1541">1541</span> |[Minimum Insertions to Balance a Parentheses String](https://leetcode.com/problems/minimum-insertions-to-balance-a-parentheses-string"平衡括号字符串的最少插入次数")|[Go](problems/minimum-insertions-to-balance-a-parentheses-string)| Medium |
80
86
| <spanid="1540">1540</span> |[Can Convert String in K Moves](https://leetcode.com/problems/can-convert-string-in-k-moves"K 次操作转变字符串")|[Go](problems/can-convert-string-in-k-moves)| Medium |
| <spanid="1520">1520</span> |[Maximum Number of Non-Overlapping Substrings](https://leetcode.com/problems/maximum-number-of-non-overlapping-substrings"最多的不重叠子字符串")|[Go](problems/maximum-number-of-non-overlapping-substrings)| Hard |
101
107
| <spanid="1519">1519</span> |[Number of Nodes in the Sub-Tree With the Same Label](https://leetcode.com/problems/number-of-nodes-in-the-sub-tree-with-the-same-label"子树中标签相同的节点数")|[Go](problems/number-of-nodes-in-the-sub-tree-with-the-same-label)| Medium |
| <spanid="1516">1516</span> |[Move Sub-Tree of N-Ary Tree](https://leetcode.com/problems/move-sub-tree-of-n-ary-tree"移动 N 叉树的子树") 🔒 |[Go](problems/move-sub-tree-of-n-ary-tree)| Hard |
105
111
| <spanid="1515">1515</span> |[Best Position for a Service Centre](https://leetcode.com/problems/best-position-for-a-service-centre"服务中心的最佳位置")|[Go](problems/best-position-for-a-service-centre)| Hard |
106
112
| <spanid="1514">1514</span> |[Path with Maximum Probability](https://leetcode.com/problems/path-with-maximum-probability"概率最大的路径")|[Go](problems/path-with-maximum-probability)| Medium |
107
113
| <spanid="1513">1513</span> |[Number of Substrings With Only 1s](https://leetcode.com/problems/number-of-substrings-with-only-1s"仅含 1 的子串数")|[Go](problems/number-of-substrings-with-only-1s)| Medium |
108
114
| <spanid="1512">1512</span> |[Number of Good Pairs](https://leetcode.com/problems/number-of-good-pairs"好数对的数目")|[Go](problems/number-of-good-pairs)| Easy |
109
-
| <spanid="1511">1511</span> |[Customer Order Frequency](https://leetcode.com/problems/customer-order-frequency) 🔒 |[MySQL](problems/customer-order-frequency)| Easy |
115
+
| <spanid="1511">1511</span> |[Customer Order Frequency](https://leetcode.com/problems/customer-order-frequency"消费者下单频率") 🔒 |[MySQL](problems/customer-order-frequency)| Easy |
110
116
| <spanid="1510">1510</span> |[Stone Game IV](https://leetcode.com/problems/stone-game-iv"石子游戏 IV")|[Go](problems/stone-game-iv)| Hard |
111
117
| <spanid="1509">1509</span> |[Minimum Difference Between Largest and Smallest Value in Three Moves](https://leetcode.com/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves"三次操作后最大值与最小值的最小差")|[Go](problems/minimum-difference-between-largest-and-smallest-value-in-three-moves)| Medium |
112
118
| <spanid="1508">1508</span> |[Range Sum of Sorted Subarray Sums](https://leetcode.com/problems/range-sum-of-sorted-subarray-sums"子数组和排序后的区间和")|[Go](problems/range-sum-of-sorted-subarray-sums)| Medium |
@@ -400,7 +406,7 @@ LeetCode Problems' Solutions
400
406
| <spanid="1220">1220</span> |[Count Vowels Permutation](https://leetcode.com/problems/count-vowels-permutation"统计元音字母序列的数目")|[Go](problems/count-vowels-permutation)| Hard |
401
407
| <spanid="1219">1219</span> |[Path with Maximum Gold](https://leetcode.com/problems/path-with-maximum-gold"黄金矿工")|[Go](problems/path-with-maximum-gold)| Medium |
402
408
| <spanid="1218">1218</span> |[Longest Arithmetic Subsequence of Given Difference](https://leetcode.com/problems/longest-arithmetic-subsequence-of-given-difference"最长定差子序列")|[Go](problems/longest-arithmetic-subsequence-of-given-difference)| Medium |
403
-
| <spanid="1217">1217</span> |[Play with Chips](https://leetcode.com/problems/play-with-chips"玩筹码")|[Go](problems/play-with-chips)| Easy |
409
+
| <spanid="1217">1217</span> |[Minimum Cost to Move Chips to The Same Position](https://leetcode.com/problems/minimum-cost-to-move-chips-to-the-same-position"玩筹码")|[Go](problems/minimum-cost-to-move-chips-to-the-same-position)| Easy |
404
410
| <spanid="1216">1216</span> |[Valid Palindrome III](https://leetcode.com/problems/valid-palindrome-iii"验证回文字符串 III") 🔒 |[Go](problems/valid-palindrome-iii)| Hard |
405
411
| <spanid="1215">1215</span> |[Stepping Numbers](https://leetcode.com/problems/stepping-numbers"步进数") 🔒 |[Go](problems/stepping-numbers)| Medium |
406
412
| <spanid="1214">1214</span> |[Two Sum BSTs](https://leetcode.com/problems/two-sum-bsts"查找两棵二叉搜索树之和") 🔒 |[Go](problems/two-sum-bsts)| Medium |
Copy file name to clipboardExpand all lines: problems/can-i-win/README.md
+32-17Lines changed: 32 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,34 +11,49 @@
11
11
12
12
## [464. Can I Win (Medium)](https://leetcode.com/problems/can-i-win"我能赢吗")
13
13
14
-
<p>In the "100 game," two players take turns adding, to a running total, any integer from 1..10. The player who first causes the running total to reach or exceed 100 wins.</p>
14
+
<p>In the "100 game" two players take turns adding, to a running total, any integer from <code>1</code> to <code>10</code>. The player who first causes the running total to <strong>reach or exceed</strong> 100 wins.</p>
15
15
16
-
<p>What if we change the game so that players cannot re-use integers?</p>
16
+
<p>What if we change the game so that players <strong>cannot</strong> re-use integers?</p>
17
17
18
-
<p>For example, two players might take turns drawing from a common pool of numbers of 1..15 without replacement until they reach a total >= 100.</p>
18
+
<p>For example, two players might take turns drawing from a common pool of numbers from 1 to 15 without replacement until they reach a total >= 100.</p>
19
19
20
-
<p>Given an integer <code>maxChoosableInteger</code> and another integer <code>desiredTotal</code>, determine if the first player to move can force a win, assuming both players play optimally. </p>
20
+
<p>Given two integers maxChoosableInteger and desiredTotal, return <code>true</code>if the first player to move can force a win, otherwise return <code>false</code>. Assume both players play <strong>optimally</strong>.</p>
21
21
22
-
<p>You can always assume that <code>maxChoosableInteger</code> will not be larger than 20 and <code>desiredTotal</code> will not be larger than 300.
## [211. Design Add and Search Words Data Structure (Medium)](https://leetcode.com/problems/design-add-and-search-words-data-structure"添加与搜索单词 - 数据结构设计")
13
+
14
+
<p>You should design a data structure that supports adding new words and finding if a string matches any previously added string.</p>
15
+
16
+
<p>Implement the <code>WordDictionary</code> class:</p>
17
+
18
+
<ul>
19
+
<li><code>WordDictionary()</code> Initializes the object.</li>
20
+
<li><code>void addWord(word)</code> adds <code>word</code> to the data structure, it can be matched later.</li>
21
+
<li><code>bool search(word)</code> returns <code>true</code> if there is any string in the data structure that matches <code>word</code> or <code>false</code> otherwise. <code>word</code> may contain dots <code>'.'</code> where dots can be matched with any letter.</li>
1.[Prefix and Suffix Search](../prefix-and-suffix-search) (Hard)
63
+
64
+
### Hints
65
+
<details>
66
+
<summary>Hint 1</summary>
67
+
You should be familiar with how a Trie works. If not, please work on this problem: <ahref="https://leetcode.com/problems/implement-trie-prefix-tree/">Implement Trie (Prefix Tree)</a> first.
Given an integer array with <b>even</b> length, where different numbers in this array represent different <b>kinds</b> of candies. Each number means one candy of the corresponding kind. You need to distribute these candies <b>equally</b> in number to brother and sister. Return the maximum number of <b>kinds</b> of candies the sister could gain.
14
+
<p>You have <code>n</code> <code>candies</code> of different types, the <code>i<sup>th</sup></code> candy is of type <code>candies[i]</code>.</p>
15
+
16
+
<p>You want to distribute the candies equally between a sister and a brother so that each of them gets <code>n / 2</code> candies (<code>n</code> is even). The sister loves to collect different types of candies, so you want to give her the <strong>maximum number of different types</strong> of candies.</p>
17
+
18
+
<p>Return <em>the maximum number of different types</em> of candies you can give to the sister.</p>
19
+
20
+
<ol>
21
+
</ol>
22
+
23
+
<p> </p>
24
+
<p><strong>Example 1:</strong></p>
15
25
16
-
<p><b>Example 1:</b><br />
17
26
<pre>
18
-
<b>Input:</b> candies = [1,1,2,2,3,3]
19
-
<b>Output:</b> 3
20
-
<b>Explanation:</b>
27
+
<strong>Input:</strong> candies = [1,1,2,2,3,3]
28
+
<strong>Output:</strong> 3
29
+
<strong>Explanation:</strong>
21
30
There are three different kinds of candies (1, 2 and 3), and two candies for each kind.
22
31
Optimal distribution: The sister has candies [1,2,3] and the brother has candies [1,2,3], too.
23
32
The sister has three different kinds of candies.
24
33
</pre>
25
-
</p>
26
34
27
-
<p><b>Example 2:</b><br />
35
+
<p><strong>Example 2:</strong></p>
36
+
28
37
<pre>
29
-
<b>Input:</b> candies = [1,1,2,3]
30
-
<b>Output:</b> 2
31
-
<b>Explanation:</b> For example, the sister has candies [2,3] and the brother has candies [1,1].
32
-
The sister has two different kinds of candies, the brother has only one kind of candies.
38
+
<strong>Input:</strong> candies = [1,1,2,3]
39
+
<strong>Output:</strong> 2
40
+
<strong>Explanation:</strong> For example, the sister has candies [2,3] and the brother has candies [1,1].
41
+
The sister has two different kinds of candies, the brother has only one kind of candies.
33
42
</pre>
34
-
</p>
35
43
36
-
<p><b>Note:</b>
37
-
<ol>
38
-
<li>The length of the given array is in range [2, 10,000], and will be even.</li>
39
-
<li>The number in given array is in range [-100,000, 100,000].</li>
0 commit comments