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
+25-3
Original file line number
Diff line number
Diff line change
@@ -70,6 +70,28 @@ LeetCode Problems' Solutions
70
70
71
71
| # | Title | Solution | Difficulty |
72
72
| :-: | - | - | :-: |
73
+
| <spanid="1681">1681</span> |[Minimum Incompatibility](https://leetcode.com/problems/minimum-incompatibility"最小不兼容性")|[Go](problems/minimum-incompatibility)| Hard |
74
+
| <spanid="1680">1680</span> |[Concatenation of Consecutive Binary Numbers](https://leetcode.com/problems/concatenation-of-consecutive-binary-numbers"连接连续二进制数字")|[Go](problems/concatenation-of-consecutive-binary-numbers)| Medium |
75
+
| <spanid="1679">1679</span> |[Max Number of K-Sum Pairs](https://leetcode.com/problems/max-number-of-k-sum-pairs"K 和数对的最大数目")|[Go](problems/max-number-of-k-sum-pairs)| Medium |
| <spanid="1677">1677</span> |[Product's Worth Over Invoices](https://leetcode.com/problems/products-worth-over-invoices) 🔒 |[MySQL](problems/products-worth-over-invoices)| Easy |
78
+
| <spanid="1676">1676</span> |[Lowest Common Ancestor of a Binary Tree IV](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree-iv) 🔒 |[Go](problems/lowest-common-ancestor-of-a-binary-tree-iv)| Medium |
79
+
| <spanid="1675">1675</span> |[Minimize Deviation in Array](https://leetcode.com/problems/minimize-deviation-in-array"数组的最小偏移量")|[Go](problems/minimize-deviation-in-array)| Hard |
80
+
| <spanid="1674">1674</span> |[Minimum Moves to Make Array Complementary](https://leetcode.com/problems/minimum-moves-to-make-array-complementary"使数组互补的最少操作次数")|[Go](problems/minimum-moves-to-make-array-complementary)| Medium |
81
+
| <spanid="1673">1673</span> |[Find the Most Competitive Subsequence](https://leetcode.com/problems/find-the-most-competitive-subsequence"找出最具竞争力的子序列")|[Go](problems/find-the-most-competitive-subsequence)| Medium |
| <spanid="1671">1671</span> |[Minimum Number of Removals to Make Mountain Array](https://leetcode.com/problems/minimum-number-of-removals-to-make-mountain-array"得到山形数组的最少删除次数")|[Go](problems/minimum-number-of-removals-to-make-mountain-array)| Hard |
84
+
| <spanid="1670">1670</span> |[Design Front Middle Back Queue](https://leetcode.com/problems/design-front-middle-back-queue"设计前中后队列")|[Go](problems/design-front-middle-back-queue)| Medium |
85
+
| <spanid="1669">1669</span> |[Merge In Between Linked Lists](https://leetcode.com/problems/merge-in-between-linked-lists"合并两个链表")|[Go](problems/merge-in-between-linked-lists)| Medium |
| <spanid="1667">1667</span> |[Fix Names in a Table](https://leetcode.com/problems/fix-names-in-a-table) 🔒 |[MySQL](problems/fix-names-in-a-table)| Easy |
88
+
| <spanid="1666">1666</span> |[Change the Root of a Binary Tree](https://leetcode.com/problems/change-the-root-of-a-binary-tree) 🔒 |[Go](problems/change-the-root-of-a-binary-tree)| Medium |
89
+
| <spanid="1665">1665</span> |[Minimum Initial Energy to Finish Tasks](https://leetcode.com/problems/minimum-initial-energy-to-finish-tasks"完成所有任务的最少初始能量")|[Go](problems/minimum-initial-energy-to-finish-tasks)| Hard |
90
+
| <spanid="1664">1664</span> |[Ways to Make a Fair Array](https://leetcode.com/problems/ways-to-make-a-fair-array"生成平衡数组的方案数")|[Go](problems/ways-to-make-a-fair-array)| Medium |
91
+
| <spanid="1663">1663</span> |[Smallest String With A Given Numeric Value](https://leetcode.com/problems/smallest-string-with-a-given-numeric-value"具有给定数值的最小字符串")|[Go](problems/smallest-string-with-a-given-numeric-value)| Medium |
92
+
| <spanid="1662">1662</span> |[Check If Two String Arrays are Equivalent](https://leetcode.com/problems/check-if-two-string-arrays-are-equivalent"检查两个字符串数组是否相等")|[Go](problems/check-if-two-string-arrays-are-equivalent)| Easy |
93
+
| <spanid="1661">1661</span> |[Average Time of Process per Machine](https://leetcode.com/problems/average-time-of-process-per-machine) 🔒 |[MySQL](problems/average-time-of-process-per-machine)| Easy |
94
+
| <spanid="1660">1660</span> |[Correct a Binary Tree](https://leetcode.com/problems/correct-a-binary-tree"纠正二叉树") 🔒 |[Go](problems/correct-a-binary-tree)| Medium |
73
95
| <spanid="1659">1659</span> |[Maximize Grid Happiness](https://leetcode.com/problems/maximize-grid-happiness"最大化网格幸福感")|[Go](problems/maximize-grid-happiness)| Hard |
74
96
| <spanid="1658">1658</span> |[Minimum Operations to Reduce X to Zero](https://leetcode.com/problems/minimum-operations-to-reduce-x-to-zero"将 x 减到 0 的最小操作数")|[Go](problems/minimum-operations-to-reduce-x-to-zero)| Medium |
75
97
| <spanid="1657">1657</span> |[Determine if Two Strings Are Close](https://leetcode.com/problems/determine-if-two-strings-are-close"确定两个字符串是否接近")|[Go](problems/determine-if-two-strings-are-close)| Medium |
@@ -79,7 +101,7 @@ LeetCode Problems' Solutions
79
101
| <spanid="1653">1653</span> |[Minimum Deletions to Make String Balanced](https://leetcode.com/problems/minimum-deletions-to-make-string-balanced"使字符串平衡的最少删除次数")|[Go](problems/minimum-deletions-to-make-string-balanced)| Medium |
80
102
| <spanid="1652">1652</span> |[Defuse the Bomb](https://leetcode.com/problems/defuse-the-bomb"拆炸弹")|[Go](problems/defuse-the-bomb)| Easy |
81
103
| <spanid="1651">1651</span> |[Hopper Company Queries III](https://leetcode.com/problems/hopper-company-queries-iii) 🔒 |[MySQL](problems/hopper-company-queries-iii)| Hard |
82
-
| <spanid="1650">1650</span> |[Lowest Common Ancestor of a Binary Tree III](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree-iii) 🔒 |[Go](problems/lowest-common-ancestor-of-a-binary-tree-iii)| Medium |
104
+
| <spanid="1650">1650</span> |[Lowest Common Ancestor of a Binary Tree III](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree-iii"二叉树的最近公共祖先 III") 🔒 |[Go](problems/lowest-common-ancestor-of-a-binary-tree-iii)| Medium |
83
105
| <spanid="1649">1649</span> |[Create Sorted Array through Instructions](https://leetcode.com/problems/create-sorted-array-through-instructions"通过指令创建有序数组")|[Go](problems/create-sorted-array-through-instructions)| Hard |
84
106
| <spanid="1648">1648</span> |[Sell Diminishing-Valued Colored Balls](https://leetcode.com/problems/sell-diminishing-valued-colored-balls"销售价值减少的颜色球")|[Go](problems/sell-diminishing-valued-colored-balls)| Medium |
85
107
| <spanid="1647">1647</span> |[Minimum Deletions to Make Character Frequencies Unique](https://leetcode.com/problems/minimum-deletions-to-make-character-frequencies-unique"字符频次唯一的最小删除次数")|[Go](problems/minimum-deletions-to-make-character-frequencies-unique)| Medium |
@@ -149,7 +171,7 @@ LeetCode Problems' Solutions
149
171
| <spanid="1583">1583</span> |[Count Unhappy Friends](https://leetcode.com/problems/count-unhappy-friends"统计不开心的朋友")|[Go](problems/count-unhappy-friends)| Medium |
150
172
| <spanid="1582">1582</span> |[Special Positions in a Binary Matrix](https://leetcode.com/problems/special-positions-in-a-binary-matrix"二进制矩阵中的特殊位置")|[Go](problems/special-positions-in-a-binary-matrix)| Easy |
151
173
| <spanid="1581">1581</span> |[Customer Who Visited but Did Not Make Any Transactions](https://leetcode.com/problems/customer-who-visited-but-did-not-make-any-transactions"进店却未进行过交易的顾客") 🔒 |[MySQL](problems/customer-who-visited-but-did-not-make-any-transactions)| Easy |
152
-
| <spanid="1580">1580</span> |[Put Boxes Into the Warehouse II](https://leetcode.com/problems/put-boxes-into-the-warehouse-ii) 🔒 |[Go](problems/put-boxes-into-the-warehouse-ii)| Medium |
174
+
| <spanid="1580">1580</span> |[Put Boxes Into the Warehouse II](https://leetcode.com/problems/put-boxes-into-the-warehouse-ii"把箱子放进仓库里 II") 🔒 |[Go](problems/put-boxes-into-the-warehouse-ii)| Medium |
153
175
| <spanid="1579">1579</span> |[Remove Max Number of Edges to Keep Graph Fully Traversable](https://leetcode.com/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable"保证图可完全遍历")|[Go](problems/remove-max-number-of-edges-to-keep-graph-fully-traversable)| Hard |
154
176
| <spanid="1578">1578</span> |[Minimum Deletion Cost to Avoid Repeating Letters](https://leetcode.com/problems/minimum-deletion-cost-to-avoid-repeating-letters"避免重复字母的最小删除成本")|[Go](problems/minimum-deletion-cost-to-avoid-repeating-letters)| Medium |
155
177
| <spanid="1577">1577</span> |[Number of Ways Where Square of Number Is Equal to Product of Two Numbers](https://leetcode.com/problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers"数的平方等于两数乘积的方法数")|[Go](problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers)| Medium |
@@ -392,7 +414,7 @@ LeetCode Problems' Solutions
392
414
| <spanid="1340">1340</span> |[Jump Game V](https://leetcode.com/problems/jump-game-v"跳跃游戏 V")|[Go](problems/jump-game-v)| Hard |
393
415
| <spanid="1339">1339</span> |[Maximum Product of Splitted Binary Tree](https://leetcode.com/problems/maximum-product-of-splitted-binary-tree"分裂二叉树的最大乘积")|[Go](problems/maximum-product-of-splitted-binary-tree)| Medium |
394
416
| <spanid="1338">1338</span> |[Reduce Array Size to The Half](https://leetcode.com/problems/reduce-array-size-to-the-half"数组大小减半")|[Go](problems/reduce-array-size-to-the-half)| Medium |
395
-
| <spanid="1337">1337</span> |[The K Weakest Rows in a Matrix](https://leetcode.com/problems/the-k-weakest-rows-in-a-matrix"方阵中战斗力最弱的 K 行")|[Go](problems/the-k-weakest-rows-in-a-matrix)| Easy |
417
+
| <spanid="1337">1337</span> |[The K Weakest Rows in a Matrix](https://leetcode.com/problems/the-k-weakest-rows-in-a-matrix"矩阵中战斗力最弱的 K 行")|[Go](problems/the-k-weakest-rows-in-a-matrix)| Easy |
396
418
| <spanid="1336">1336</span> |[Number of Transactions per Visit](https://leetcode.com/problems/number-of-transactions-per-visit"每次访问的交易次数") 🔒 |[MySQL](problems/number-of-transactions-per-visit)| Hard |
397
419
| <spanid="1335">1335</span> |[Minimum Difficulty of a Job Schedule](https://leetcode.com/problems/minimum-difficulty-of-a-job-schedule"工作计划的最低难度")|[Go](problems/minimum-difficulty-of-a-job-schedule)| Hard |
398
420
| <spanid="1334">1334</span> |[Find the City With the Smallest Number of Neighbors at a Threshold Distance](https://leetcode.com/problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance"阈值距离内邻居最少的城市")|[Go](problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance)| Medium |
<li><code>s</code> consists of integers and operators <code>('+', '-', '*', '/')</code> separated by some number of spaces.</li>
Copy file name to clipboardExpand all lines: problems/binary-search-tree-iterator/README.md
+36-20
Original file line number
Diff line number
Diff line change
@@ -11,39 +11,55 @@
11
11
12
12
## [173. Binary Search Tree Iterator (Medium)](https://leetcode.com/problems/binary-search-tree-iterator"二叉搜索树迭代器")
13
13
14
-
<p>Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.</p>
15
-
16
-
<p>Calling <code>next()</code> will return the next smallest number in the BST.</p>
17
-
18
-
<p> </p>
14
+
<p>Implement the <code>BSTIterator</code> class that represents an iterator over the <strong><ahref="https://en.wikipedia.org/wiki/Tree_traversal#In-order_(LNR)">in-order traversal</a></strong> of a binary search tree (BST):</p>
19
15
20
16
<ul>
17
+
<li><code>BSTIterator(TreeNode root)</code> Initializes an object of the <code>BSTIterator</code> class. The <code>root</code> of the BST is given as part of the constructor. The pointer should be initialized to a non-existent number smaller than any element in the BST.</li>
18
+
<li><code>boolean hasNext()</code> Returns <code>true</code> if there exists a number in the traversal to the right of the pointer, otherwise returns <code>false</code>.</li>
19
+
<li><code>int next()</code> Moves the pointer to the right, then returns the number at the pointer.</li>
21
20
</ul>
22
21
23
-
<p><strong>Example:</strong></p>
22
+
<p>Notice that by initializing the pointer to a non-existent smallest number, the first call to <code>next()</code> will return the smallest element in the BST.</p>
<p>You may assume that <code>next()</code> calls will always be valid. That is, there will be at least a next number in the in-order traversal when <code>next()</code> is called.</p>
<li>At most <code>10<sup>5</sup></code> calls will be made to <code>hasNext</code>, and <code>next</code>.</li>
56
+
</ul>
57
+
58
+
<p> </p>
59
+
<p><strong>Follow up:</strong></p>
43
60
44
61
<ul>
45
-
<li><code>next()</code> and <code>hasNext()</code> should run in average O(1) time and uses O(<i>h</i>) memory, where <i>h</i> is the height of the tree.</li>
46
-
<li>You may assume that <code>next()</code> call will always be valid, that is, there will be at least a next smallest number in the BST when <code>next()</code> is called.</li>
62
+
<li>Could you implement <code>next()</code> and <code>hasNext()</code> to run in average <code>O(1)</code> time and use <code>O(h)</code> memory, where <code>h</code> is the height of the tree?</li>
0 commit comments