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
+13-4Lines changed: 13 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -54,6 +54,15 @@ LeetCode Problems' Solutions
54
54
55
55
| # | Title | Solution | Difficulty |
56
56
| :-: | - | - | :-: |
57
+
| <spanid="1172">1172</span> |[Dinner Plate Stacks](https://leetcode.com/problems/dinner-plate-stacks"餐盘栈")|[Go](https://github.com/openset/leetcode/tree/master/problems/dinner-plate-stacks)| Hard |
58
+
| <spanid="1171">1171</span> |[Remove Zero Sum Consecutive Nodes from Linked List](https://leetcode.com/problems/remove-zero-sum-consecutive-nodes-from-linked-list"从链表中删去总和值为零的连续节点")|[Go](https://github.com/openset/leetcode/tree/master/problems/remove-zero-sum-consecutive-nodes-from-linked-list)| Medium |
59
+
| <spanid="1170">1170</span> |[Compare Strings by Frequency of the Smallest Character](https://leetcode.com/problems/compare-strings-by-frequency-of-the-smallest-character"比较字符串最小字母出现频次")|[Go](https://github.com/openset/leetcode/tree/master/problems/compare-strings-by-frequency-of-the-smallest-character)| Easy |
| <spanid="1168">1168</span> |[Optimize Water Distribution in a Village](https://leetcode.com/problems/optimize-water-distribution-in-a-village"水资源分配优化") 🔒 |[Go](https://github.com/openset/leetcode/tree/master/problems/optimize-water-distribution-in-a-village)| Hard |
62
+
| <spanid="1167">1167</span> |[Minimum Cost to Connect Sticks](https://leetcode.com/problems/minimum-cost-to-connect-sticks"连接棒材的最低费用") 🔒 |[Go](https://github.com/openset/leetcode/tree/master/problems/minimum-cost-to-connect-sticks)| Medium |
63
+
| <spanid="1166">1166</span> |[Design File System](https://leetcode.com/problems/design-file-system"设计文件系统") 🔒 |[Go](https://github.com/openset/leetcode/tree/master/problems/design-file-system)| Medium |
| <spanid="1164">1164</span> |[Product Price at a Given Date](https://leetcode.com/problems/product-price-at-a-given-date) 🔒 |[MySQL](https://github.com/openset/leetcode/tree/master/problems/product-price-at-a-given-date)| Medium |
57
66
| <spanid="1163">1163</span> |[Last Substring in Lexicographical Order](https://leetcode.com/problems/last-substring-in-lexicographical-order"按字典序排在最后的子串")|[Go](https://github.com/openset/leetcode/tree/master/problems/last-substring-in-lexicographical-order)| Hard |
58
67
| <spanid="1162">1162</span> |[As Far from Land as Possible](https://leetcode.com/problems/as-far-from-land-as-possible"地图分析")|[Go](https://github.com/openset/leetcode/tree/master/problems/as-far-from-land-as-possible)| Medium |
59
68
| <spanid="1161">1161</span> |[Maximum Level Sum of a Binary Tree](https://leetcode.com/problems/maximum-level-sum-of-a-binary-tree"最大层内元素和")|[Go](https://github.com/openset/leetcode/tree/master/problems/maximum-level-sum-of-a-binary-tree)| Medium |
@@ -119,7 +128,7 @@ LeetCode Problems' Solutions
119
128
| <spanid="1101">1101</span> |[The Earliest Moment When Everyone Become Friends](https://leetcode.com/problems/the-earliest-moment-when-everyone-become-friends"彼此熟识的最早时间") 🔒 |[Go](https://github.com/openset/leetcode/tree/master/problems/the-earliest-moment-when-everyone-become-friends)| Medium |
120
129
| <spanid="1100">1100</span> |[Find K-Length Substrings With No Repeated Characters](https://leetcode.com/problems/find-k-length-substrings-with-no-repeated-characters"长度为 K 的无重复字符子串") 🔒 |[Go](https://github.com/openset/leetcode/tree/master/problems/find-k-length-substrings-with-no-repeated-characters)| Medium |
121
130
| <spanid="1099">1099</span> |[Two Sum Less Than K](https://leetcode.com/problems/two-sum-less-than-k"小于 K 的两数之和") 🔒 |[Go](https://github.com/openset/leetcode/tree/master/problems/two-sum-less-than-k)| Easy |
122
-
| <spanid="1098">1098</span> |[Unpopular Books](https://leetcode.com/problems/unpopular-books) 🔒 |[MySQL](https://github.com/openset/leetcode/tree/master/problems/unpopular-books)| Medium |
131
+
| <spanid="1098">1098</span> |[Unpopular Books](https://leetcode.com/problems/unpopular-books"小众书籍") 🔒 |[MySQL](https://github.com/openset/leetcode/tree/master/problems/unpopular-books)| Medium |
123
132
| <spanid="1097">1097</span> |[Game Play Analysis V](https://leetcode.com/problems/game-play-analysis-v) 🔒 |[MySQL](https://github.com/openset/leetcode/tree/master/problems/game-play-analysis-v)| Hard |
124
133
| <spanid="1096">1096</span> |[Brace Expansion II](https://leetcode.com/problems/brace-expansion-ii"花括号展开 II")|[Go](https://github.com/openset/leetcode/tree/master/problems/brace-expansion-ii)| Hard |
125
134
| <spanid="1095">1095</span> |[Find in Mountain Array](https://leetcode.com/problems/find-in-mountain-array"山脉数组中查找目标值")|[Go](https://github.com/openset/leetcode/tree/master/problems/find-in-mountain-array)| Hard |
| <spanid="1085">1085</span> |[Sum of Digits in the Minimum Number](https://leetcode.com/problems/sum-of-digits-in-the-minimum-number"最小元素各数位之和") 🔒 |[Go](https://github.com/openset/leetcode/tree/master/problems/sum-of-digits-in-the-minimum-number)| Easy |
| <spanid="1081">1081</span> |[Smallest Subsequence of Distinct Characters](https://leetcode.com/problems/smallest-subsequence-of-distinct-characters"不同字符的最小子序列")|[Go](https://github.com/openset/leetcode/tree/master/problems/smallest-subsequence-of-distinct-characters)| Medium |
140
149
| <spanid="1080">1080</span> |[Insufficient Nodes in Root to Leaf Paths](https://leetcode.com/problems/insufficient-nodes-in-root-to-leaf-paths"根到叶路径上的不足节点")|[Go](https://github.com/openset/leetcode/tree/master/problems/insufficient-nodes-in-root-to-leaf-paths)| Medium |
141
150
| <spanid="1079">1079</span> |[Letter Tile Possibilities](https://leetcode.com/problems/letter-tile-possibilities"活字印刷")|[Go](https://github.com/openset/leetcode/tree/master/problems/letter-tile-possibilities)| Medium |
142
151
| <spanid="1078">1078</span> |[Occurrences After Bigram](https://leetcode.com/problems/occurrences-after-bigram"Bigram 分词")|[Go](https://github.com/openset/leetcode/tree/master/problems/occurrences-after-bigram)| Easy |
143
-
| <spanid="1077">1077</span> |[Project Employees III](https://leetcode.com/problems/project-employees-iii) 🔒 |[MySQL](https://github.com/openset/leetcode/tree/master/problems/project-employees-iii)| Medium |
152
+
| <spanid="1077">1077</span> |[Project Employees III](https://leetcode.com/problems/project-employees-iii"项目员工 III") 🔒 |[MySQL](https://github.com/openset/leetcode/tree/master/problems/project-employees-iii)| Medium |
| <spanid="1074">1074</span> |[Number of Submatrices That Sum to Target](https://leetcode.com/problems/number-of-submatrices-that-sum-to-target"元素和为目标值的子矩阵数量")|[Go](https://github.com/openset/leetcode/tree/master/problems/number-of-submatrices-that-sum-to-target)| Hard |
147
156
| <spanid="1073">1073</span> |[Adding Two Negabinary Numbers](https://leetcode.com/problems/adding-two-negabinary-numbers"负二进制数相加")|[Go](https://github.com/openset/leetcode/tree/master/problems/adding-two-negabinary-numbers)| Medium |
148
157
| <spanid="1072">1072</span> |[Flip Columns For Maximum Number of Equal Rows](https://leetcode.com/problems/flip-columns-for-maximum-number-of-equal-rows"按列翻转得到最大值等行数")|[Go](https://github.com/openset/leetcode/tree/master/problems/flip-columns-for-maximum-number-of-equal-rows)| Medium |
149
158
| <spanid="1071">1071</span> |[Greatest Common Divisor of Strings](https://leetcode.com/problems/greatest-common-divisor-of-strings"字符串的最大公因子")|[Go](https://github.com/openset/leetcode/tree/master/problems/greatest-common-divisor-of-strings)| Easy |
150
159
| <spanid="1070">1070</span> |[Product Sales Analysis III](https://leetcode.com/problems/product-sales-analysis-iii) 🔒 |[MySQL](https://github.com/openset/leetcode/tree/master/problems/product-sales-analysis-iii)| Medium |
| <spanid="1067">1067</span> |[Digit Count in Range](https://leetcode.com/problems/digit-count-in-range"范围内的数字计数") 🔒 |[Go](https://github.com/openset/leetcode/tree/master/problems/digit-count-in-range)| Hard |
154
163
| <spanid="1066">1066</span> |[Campus Bikes II](https://leetcode.com/problems/campus-bikes-ii"校园自行车分配 II") 🔒 |[Go](https://github.com/openset/leetcode/tree/master/problems/campus-bikes-ii)| Medium |
[Next >](https://github.com/openset/leetcode/tree/master/problems/remove-zero-sum-consecutive-nodes-from-linked-list"Remove Zero Sum Consecutive Nodes from Linked List")
11
+
12
+
## 1170. Compare Strings by Frequency of the Smallest Character (Easy)
13
+
14
+
<p>Let's define a function <code>f(s)</code> over a non-empty string <code>s</code>, which calculates the frequency of the smallest character in <code>s</code>. For example, if <code>s = "dcce"</code> then <code>f(s) = 2</code> because the smallest character is <code>"c"</code> and its frequency is 2.</p>
15
+
16
+
<p>Now, given string arrays <code>queries</code> and <code>words</code>, return an integer array <code>answer</code>, where each <code>answer[i]</code> is the number of words such that <code>f(queries[i])</code> < <code>f(W)</code>, where <code>W</code> is a word in <code>words</code>.</p>
17
+
18
+
<p> </p>
19
+
<p><strong>Example 1:</strong></p>
20
+
21
+
<pre>
22
+
<strong>Input:</strong> queries = ["cbd"], words = ["zaaaz"]
23
+
<strong>Output:</strong> [1]
24
+
<strong>Explanation:</strong> On the first query we have f("cbd") = 1, f("zaaaz") = 3 so f("cbd") < f("zaaaz").
25
+
</pre>
26
+
27
+
<p><strong>Example 2:</strong></p>
28
+
29
+
<pre>
30
+
<strong>Input:</strong> queries = ["bbb","cc"], words = ["a","aa","aaa","aaaa"]
31
+
<strong>Output:</strong> [1,2]
32
+
<strong>Explanation:</strong> On the first query only f("bbb") < f("aaaa"). On the second query both f("aaa") and f("aaaa") are both > f("cc").
For each string from words calculate the leading count and store it in an array, then sort the integer array.
53
+
</details>
54
+
55
+
<details>
56
+
<summary>Hint 2</summary>
57
+
For each string from queries calculate the leading count "p" and in base of the sorted array calculated on the step 1 do a binary search to count the number of items greater than "p".
0 commit comments