Skip to content

Commit 5f01ba8

Browse files
committedJun 23, 2022
update: 94
1 parent f0d0d56 commit 5f01ba8

File tree

2 files changed

+208
-141
lines changed

2 files changed

+208
-141
lines changed
 

‎README.md

Lines changed: 143 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -6,144 +6,146 @@ This is the solutions collection of my LeetCode submissions, most of them are pr
66

77
**Progress: 127 Solutions**
88

9-
| ID | Title | Solution | Difficulty |
10-
|---| ----- | -------- | ---------- |
11-
|1|[Two Sum](https://leetcode.com/problems/two-sum/) | [JavaScript](./src/two-sum/res.js)|Easy|
12-
|2|[Add Two Numbers](https://leetcode.com/problems/add-two-numbers/) | [JavaScript](./src/add-two-numbers/res.js)|Medium|
13-
|3|[Longest Substring Without Repeating Characters](https://leetcode.com/problems/longest-substring-without-repeating-characters/) | [JavaScript](./src/longest-substring-without-repeating-characters/res.js) |Medium|
14-
|4|[Median of Two Sorted Arrays](https://leetcode.com/problems/median-of-two-sorted-arrays/) | [JavaScript](./src/median-of-two-sorted-arrays/res.js) |Hard|
15-
|5|[Longest Palindromic Substring](https://leetcode.com/problems/longest-palindromic-substring/) | [JavaScript](./src/longest-palindromic-substring/res.js) |Medium|
16-
|6|[ZigZag Conversion](https://leetcode.com/problems/zigzag-conversion/) | [JavaScript](./src/zigzag-conversion/res.js) |Medium|
17-
|7|[Reverse Integer](https://leetcode.com/problems/reverse-integer/) | [JavaScript](./src/reverse-integer/res.js)|Easy|
18-
|8|[String to Integer (atoi)](https://leetcode.com/problems/string-to-integer-atoi/) | [JavaScript](./src/string-to-integer-atoi/res.js)|Medium|
19-
|11|[Container With Most Water](https://leetcode.com/problems/container-with-most-water/) | [JavaScript](./src/container-with-most-water/res.js)|Medium|
20-
|13|[Roman to Integer](https://leetcode.com/problems/roman-to-integer/) | [JavaScript](./src/roman-to-integer/res.js)|Easy|
21-
|14|[Longest Common Prefix](https://leetcode.com/problems/longest-common-prefix/) | [JavaScript](./src/longest-common-prefix/res.js)|Easy|
22-
|15|[3Sum](https://leetcode.com/problems/3sum/) | [JavaScript](./src/3sum/res.js) |Medium|
23-
|16|[3Sum Closest](https://leetcode.com/problems/3sum-closest/) | [JavaScript](./src/3sum-closest/res.js) |Medium|
24-
|17|[Letter Combinations of a Phone Number](https://leetcode.com/problems/letter-combinations-of-a-phone-number/) | [JavaScript](./src/letter-combinations-of-a-phone-number/res.js)|Medium|
25-
|19|[Remove Nth Node From End of List](https://leetcode.com/problems/remove-nth-node-from-end-of-list/) | [JavaScript](./src/remove-nth-node-from-end-of-list/res.js)|Medium|
26-
|22|[Generate Parentheses](https://leetcode.com/problems/generate-parentheses/) | [JavaScript](./src/generate-parentheses/res.js)|Medium|
27-
|26|[Remove Duplicates from Sorted Array](https://leetcode.com/problems/remove-duplicates-from-sorted-array/) | [JavaScript](./src/remove-duplicates-from-sorted-array/res.js)|Easy|
28-
|27|[Remove Element](https://leetcode.com/problems/remove-element/) | [JavaScript](./src/remove-element/res.js)|Easy|
29-
|28|[Implement strStr()](https://leetcode.com/problems/implement-strstr/) | [JavaScript](./src/implement-strstr/res.js)|Easy|
30-
|29|[Divide Two Integers](https://leetcode.com/problems/divide-two-integers/) | [JavaScript](./src/divide-two-integers/res.js)|Medium|
31-
|33|[Search in Rotated Sorted Array](https://leetcode.com/problems/search-in-rotated-sorted-array/) | [JavaScript](./src/search-in-rotated-sorted-array/res.js)|Medium|
32-
|34|[Search for a Range](https://leetcode.com/problems/search-for-a-range/) | [JavaScript](./src/search-for-a-range/res.js)|Medium|
33-
|35|[Search Insert Position](https://leetcode.com/problems/search-insert-position/) | [JavaScript](./src/search-insert-position/res.js)|Easy|
34-
|39|[Combination Sum](https://leetcode.com/problems/combination-sum/) | [JavaScript](./src/combination-sum/res.js)|Medium|
35-
|40|[Combination Sum II](https://leetcode.com/problems/combination-sum-ii/) | [JavaScript](./src/combination-sum-ii/res.js)|Medium|
36-
|41|[First Missing Positive](https://leetcode.com/problems/first-missing-positive/description/) | [JavaScript](./src/first-missing-positive/res.js)|Hard|
37-
|42|[ Trapping Rain Water](https://leetcode.com/problems/trapping-rain-water/description/) | [JavaScript](./src/trapping-rain-water/res.js)|Hard|
38-
|43|[Multiply Strings](https://leetcode.com/problems/multiply-strings/) | [JavaScript](./src/multiply-strings/res.js)|Medium|
39-
|45|[Jump Game II](https://leetcode.com/problems/jump-game-ii/) | [JavaScript](./src/jump-game-ii/res.js)|Hard|
40-
|46|[Permutations](https://leetcode.com/problems/permutations/) | [JavaScript](./src/permutations/res.js)|Medium|
41-
|48|[Rotate Image](https://leetcode.com/problems/rotate-image/) | [JavaScript](./src/rotate-image/res.js)|Medium|
42-
|49|[Group Anagrams](https://leetcode.com/problems/anagrams/) | [JavaScript](./src/anagrams/res.js)|Medium|
43-
|53|[Maximum Subarray](https://leetcode.com/problems/maximum-subarray/) | [JavaScript](./src/maximum-subarray/res.js)|Easy|
44-
|54|[Spiral Matrix](https://leetcode.com/problems/spiral-matrix/) | [JavaScript](./src/spiral-matrix/res.js)|Medium|
45-
|55|[Jump Game](https://leetcode.com/problems/jump-game/) <sup>*</sup> | [JavaScript](./src/jump-game/res.js)|Medium|
46-
|56|[Merge Intervals](https://leetcode.com/problems/merge-intervals/) | [JavaScript](./src/merge-intervals/res.js)|Medium|
47-
|57|[Insert Interval](https://leetcode.com/problems/insert-interval/) | [JavaScript](./src/insert-interval/res.js)|Hard|
48-
|62|[Unique Paths](https://leetcode.com/problems/unique-paths/) | [JavaScript](./src/unique-paths/res.js)|Medium|
49-
|63|[Unique Paths ii](https://leetcode.com/problems/unique-paths-ii/) | [JavaScript](./src/unique-paths-ii/res.js)|Medium|
50-
|66|[Plus One](https://leetcode.com/problems/plus-one/) | [JavaScript](./src/plus-one/res.js)|Easy|
51-
|69|[Sqrt(x)](https://leetcode.com/problems/sqrtx/) | [JavaScript](./src/sqrtx/res.js)|Easy|
52-
|71|[Simplify Path](https://leetcode.com/problems/simplify-path/) | [JavaScript](./src/simplify-path/res.js)|Medium|
53-
|73|[Set Matrix Zeroes](https://leetcode.com/problems/set-matrix-zeroes/) | [JavaScript](./src/set-matrix-zeroes/res.js)|Medium|
54-
|75|[Sort Colors](https://leetcode.com/problems/sort-colors/) | [JavaScript](./src/sort-colors/res.js)|Medium|
55-
|80|[Remove Duplicates from Sorted Array II](https://leetcode.com/problems/remove-duplicates-from-sorted-array-ii/) | [JavaScript](./src/remove-duplicates-from-sorted-array-ii/res.js)|Medium|
56-
|81|[Search in Rotated Sorted Array II](https://leetcode.com/problems/search-in-rotated-sorted-array-ii/) | [JavaScript](./src/search-in-rotated-sorted-array-ii/res.js)|Medium|
57-
|88|[ Merge Sorted Array](https://leetcode.com/problems/merge-sorted-array/) | [JavaScript](./src/merge-sorted-array/res.js)|Medium|
58-
|91|[Decode Ways](https://leetcode.com/problems/decode-ways/) | [JavaScript](./src/decode-ways/res.js)|Medium|
59-
|93|[Restore IP Addresses](https://leetcode.com/problems/restore-ip-addresses/) | [JavaScript](./src/restore-ip-addresses/res.js)|Medium|
60-
|98|[Validate Binary Search Tree](https://leetcode.com/problems/validate-binary-search-tree/) | [JavaScript](./src/validate-binary-search-tree/res.js)|Medium|
61-
|100|[Same Tree](https://leetcode.com/problems/same-tree/) | [JavaScript](./src/same-tree/res.js)|Easy|
62-
|101|[Symmetric Tree](https://leetcode.com/problems/symmetric-tree/) | [JavaScript](./src/symmetric-tree/res.js)|Easy|
63-
|102|[Binary Tree Level Order Traversal](https://leetcode.com/problems/binary-tree-level-order-traversal/) | [JavaScript](./src/binary-tree-level-order-traversal/res.js)|Medium|
64-
|104|[Maximum Depth of Binary Tree](https://leetcode.com/problems/maximum-depth-of-binary-tree/) | [JavaScript](./src/maximum-depth-of-binary-tree/res.js)|Easy|
65-
|107|[Binary Tree Level Order Traversal II](https://leetcode.com/problems/binary-tree-level-order-traversal-ii/) | [JavaScript](./src/binary-tree-level-order-traversal-ii/res.js)|Easy|
66-
|108|[Convert Sorted Array to Binary Search Tree](https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree/) | [JavaScript](./src/convert-sorted-array-to-binary-search-tree/res.js)|Easy|
67-
|111|[Minimum Depth of Binary Tree](https://leetcode.com/problems/minimum-depth-of-binary-tree/) | [JavaScript](./src/minimum-depth-of-binary-tree/res.js)|Easy|
68-
|120|[Triangle](https://leetcode.com/problems/triangle/) | [JavaScript](./src/triangle/res.js)|Medium|
69-
|121|[Best Time to Buy and Sell Stock](https://leetcode.com/problems/best-time-to-buy-and-sell-stock/) | [JavaScript](./src/best-time-to-buy-and-sell-stock/res.js)|Easy|
70-
|122|[Best Time to Buy and Sell Stock II](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/) | [JavaScript](./src/best-time-to-buy-and-sell-stock-ii/res.js)|Easy|
71-
|123|[Best Time to Buy and Sell Stock III](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iii/) <sup>*</sup> | [JavaScript](./src/best-time-to-buy-and-sell-stock-iii/res.js)|Hard|
72-
|127|[Word Ladder](https://leetcode.com/problems/word-ladder/) | [JavaScript](./src/word-ladder/res.js)|Medium|
73-
|128|[Longest Consecutive Sequence](https://leetcode.com/problems/longest-consecutive-sequence/) | [JavaScript](./src/longest-consecutive-sequence/res.js)|Medium|
74-
|130|[Surrounded Regions](https://leetcode.com/problems/surrounded-regions/) | [JavaScript](./src/surrounded-regions/res.js)|Medium|
75-
|133|[Clone Graph](https://leetcode.com/problems/clone-graph/) | [JavaScript](./src/clone-graph/res.js)|Medium|
76-
|134|[Gas Station](https://leetcode.com/problems/gas-station/) | [JavaScript](./src/gas-station/res.js)|Medium|
77-
|135|[Candy](https://leetcode.com/problems/candy/) | [JavaScript](./src/candy/res.js)|Hard|
78-
|136|[Single Number](https://leetcode.com/problems/single-number/) | [JavaScript](./src/single-number/res.js)|Easy|
79-
|137|[Single Number II](https://leetcode.com/problems/single-number-ii/) | [JavaScript](./src/single-number-ii/res.js)|Medium|
80-
|151|[Reverse Words in a String](https://leetcode.com/problems/reverse-words-in-a-string/) | [JavaScript](./src/reverse-words-in-a-string/res.js)|Medium|
81-
|152|[Maximum Product Subarray](https://leetcode.com/problems/maximum-product-subarray/) | [JavaScript](./src/maximum-product-subarray/res.js)|Medium|
82-
|153|[Find Minimum in Rotated Sorted Array](https://leetcode.com/problems/find-minimum-in-rotated-sorted-array/) | [JavaScript](./src/find-minimum-in-rotated-sorted-array/res.js)|Medium|
83-
|154|[Find Minimum in Rotated Sorted Array II](https://leetcode.com/problems/find-minimum-in-rotated-sorted-array-ii/) | [JavaScript](./src/find-minimum-in-rotated-sorted-array-ii/res.js)|Medium|
84-
|162|[Find Peak Element](https://leetcode.com/problems/find-peak-element/) | [JavaScript](./src/find-peak-element/res.js)|Medium|
85-
|164|[Maximum Gap](https://leetcode.com/problems/maximum-gap/) | [JavaScript](./src/maximum-gap/res.js)|Hard|
86-
|165|[Compare Version Numbers](https://leetcode.com/problems/compare-version-numbers/) | [JavaScript](./src/compare-version-numbers/res.js)|Medium|
87-
|169|[Majority Element](https://leetcode.com/problems/majority-element/) | [JavaScript](./src/majority-element/res.js)|Easy|
88-
|175|[Combine Two Tables](https://leetcode.com/problems/combine-two-tables/)| [SQL](./src/combine-two-tables/res.txt)|Easy|
89-
|176|[Second Highest Salary](https://leetcode.com/problems/second-highest-salary/)| [SQL](./src/second-highest-salary/res.txt)|Easy|
90-
|177|[Nth Highest Salary](https://leetcode.com/problems/nth-highest-salary/)| [SQL](./src/nth-highest-salary/res.txt)|Medium|
91-
|181|[Employees Earning More Than Their Managers](https://leetcode.com/problems/employees-earning-more-than-their-managers/) | [SQL](./src/employees-earning-more-than-their-managers/res.txt)|Easy|
92-
|182|[Duplicate Emails](https://leetcode.com/problems/duplicate-emails/) | [SQL](./src/duplicate-emails/res.txt)|Easy|
93-
|183|[Customers Who Never Order](https://leetcode.com/problems/customers-who-never-order/) | [SQL](./src/customers-who-never-order/res.txt)|Easy|
94-
|184|[Department Highest Salary](https://leetcode.com/problems/department-highest-salary/) | [SQL](./src/department-highest-salary/res.txt)|Medium|
95-
|188|[Best Time to Buy and Sell Stock IV](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iv/) | [JavaScript](./src/best-time-to-buy-and-sell-stock-iv/res.txt)|Hard|
96-
|189|[Rotate Array](https://leetcode.com/problems/rotate-array/) | [JavaScript](./src/rotate-array/res.js)|Easy|
97-
|190|[Reverse Bits](https://leetcode.com/problems/reverse-bits/) | [JavaScript](./src/reverse-bits/res.js)|Easy|
98-
|196|[Delete Duplicate Emails](https://leetcode.com/problems/delete-duplicate-emails/) | [SQL](./src/delete-duplicate-emails/res.txt)|Easy|
99-
|197|[Rising Temperature](https://leetcode.com/problems/rising-temperature/) | [SQL](./src/rising-temperature/res.txt)|Easy|
100-
|206|[Reverse Linked List](https://leetcode.com/problems/reverse-linked-list/) | [JavaScript](./src/reverse-linked-list/res.js)|Easy|
101-
|207|[Course Schedule](https://leetcode.com/problems/course-schedule/) | [JavaScript](./src/course-schedule/res.js)|Medium|
102-
|209|[Minimum Size Subarray Sum](https://leetcode.com/problems/minimum-size-subarray-sum/) | [JavaScript](./src/minimum-size-subarray-sum/res.js)|Medium|
103-
|210|[Course Schedule II](https://leetcode.com/problems/course-schedule-ii/) | [JavaScript](./src/course-schedule-ii/res.js)|Medium|
104-
|215|[Kth Largest Element in an Array](https://leetcode.com/problems/kth-largest-element-in-an-array/) | [JavaScript](./src/kth-largest-element-in-an-array/res.js)|Medium|
105-
|217|[Contains Duplicate](https://leetcode.com/problems/contains-duplicate/) | [JavaScript](./src/contains-duplicate/res.js)|Easy|
106-
|219|[Contains Duplicate II](https://leetcode.com/problems/contains-duplicate-ii/) | [JavaScript](./src/contains-duplicate-ii/res.js)|Easy|
107-
|220|[Contains Duplicate III](https://leetcode.com/problems/contains-duplicate-iii/) | [JavaScript](./src/contains-duplicate-iii/res.js)|Medium|
108-
|228|[Summary Ranges](https://leetcode.com/problems/summary-ranges/solution/) | [JavaScript](./src/summary-ranges/res.js)|Medium|
109-
|238|[Product of Array Except Self](https://leetcode.com/problems/product-of-array-except-self/solution/) | [JavaScript](./src/product-of-array-except-self/res.js)|Medium|
110-
|239|[Sliding Window Maximum](https://leetcode.com/problems/sliding-window-maximum/description/) | [JavaScript](./src/sliding-window-maximum/description/res.js)|Hard|
111-
|240|[Search a 2D Matrix II](https://leetcode.com/problems/search-a-2d-matrix-ii/) | [JavaScript](./src/search-a-2d-matrix-ii/res.js)|Medium|
112-
|274|[H-Index](https://leetcode.com/problems/h-index/) | [JavaScript](./src/h-index/res.js)|Medium|
113-
|275|[H-Index II](https://leetcode.com/problems/h-index-ii/) | [JavaScript](./src/h-index-ii/res.js)|Medium|
114-
|278|[First Bad Version](https://leetcode.com/problems/first-bad-version/) | [JavaScript](./src/first-bad-version/res.js)|Easy|
115-
|283|[Move Zeroes](https://leetcode.com/problems/move-zeroes/) | [JavaScript](./src/move-zeroes/res.js)|Easy|
116-
|287|[Find the Duplicate Number](https://leetcode.com/problems/find-the-duplicate-number/) | [JavaScript](./src/find-the-duplicate-number/res.js)|Medium|
117-
|289|[Game of Life](https://leetcode.com/problems/game-of-life/) | [JavaScript](./src/game-of-life/res.js)|Medium|
118-
|295|[Find Median from Data Stream](https://leetcode.com/problems/find-median-from-data-stream/) | [JavaScript](./src/find-median-from-data-stream/res.js)|Hard|
119-
|299|[Bulls and Cows](https://leetcode.com/problems/bulls-and-cows/) | [JavaScript](./src/bulls-and-cows/res.js)|Medium|
120-
|300|[Longest Increasing Subsequence](https://leetcode.com/problems/longest-increasing-subsequence/) | [JavaScript](./src/longest-increasing-subsequence/res.js)|Medium|
121-
|307|[Range Sum Query - Mutable](https://leetcode.com/problems/range-sum-query-mutable/) | [JavaScript](./src/range-sum-query-mutable/res.js)|Medium|
122-
|309|[Best Time to Buy and Sell Stock with Cooldown](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-cooldown/) | [JavaScript](./src/best-time-to-buy-and-sell-stock-with-cooldown/res.js)|Medium|
123-
|310|[Minimum Height Trees](https://leetcode.com/problems/minimum-height-trees/) | [JavaScript](./src/minimum-height-trees/res.js)|Medium|
124-
|315|[Count of Smaller Numbers After Self](https://leetcode.com/problems/count-of-smaller-numbers-after-self/) <sup>*</sup> | [JavaScript](./src/count-of-smaller-numbers-after-self/res.js)|Hard|
125-
|322|[Coin Change](https://leetcode.com/problems/coin-change/) | [JavaScript](./src/coin-change/res.js)|Medium|
126-
|327|[Count of Range Sum](https://leetcode.com/problems/count-of-range-sum/) | [JavaScript](./src/count-of-range-sum/res.js)|Hard|
127-
|334|[Increasing Triplet Subsequence](https://leetcode.com/problems/increasing-triplet-subsequence/) | [JavaScript](./src/increasing-triplet-subsequence/res.js)|Medium|
128-
|340|[Longest Substring with At Most K Distinct Characters](https://leetcode.com/problems/longest-substring-with-at-most-k-distinct-characters/) | [JavaScript](./src/longest-substring-with-at-most-k-distinct-characters/res.js)|Hard|
129-
|342|[Power of Four](https://leetcode.com/problems/power-of-four/) | [JavaScript](./src/power-of-four/res.js)|Easy|
130-
|344|[Reverse String](https://leetcode.com/problems/reverse-string/) | [JavaScript](./src/reverse-string/res.js)|Easy|
131-
|349|[Intersection of Two Arrays](https://leetcode.com/problems/intersection-of-two-arrays/) | [JavaScript](./src/intersection-of-two-arrays/res.js)|Easy|
132-
|350|[Intersection of Two Arrays ii](https://leetcode.com/problems/intersection-of-two-arrays-ii/) | [JavaScript](./src/intersection-of-two-arrays-ii/res.js)|Easy|
133-
|371|[Sum of Two Integers](https://leetcode.com/problems/sum-of-two-integers/) | [JavaScript](./src/sum-of-two-integers/res.js)|Easy|
134-
|374|[Guess Number Higher or Lower](https://leetcode.com/problems/guess-number-higher-or-lower/) | [JavaScript](./src/guess-number-higher-or-lower/res.py)|Easy|
135-
|376|[Wiggle Subsequence](https://leetcode.com/problems/wiggle-subsequence/) | [JavaScript](./src/wiggle-subsequence/res.js)|Medium|
136-
|384|[Shuffle an Array](https://leetcode.com/problems/shuffle-an-array/) | [JavaScript](./src/shuffle-an-array/res.js)|Medium|
137-
|395|[Longest Substring with At Least K Repeating Characters](https://leetcode.com/problems/longest-substring-with-at-least-k-repeating-characters/) | [JavaScript](./src/longest-substring-with-at-least-k-repeating-characters/res.js)|Medium|
138-
|404|[Sum of Left Leaves](https://leetcode.com/problems/sum-of-left-leaves/) | [JavaScript](./src/sum-of-left-leaves/res.js)|Easy|
139-
|413|[Arithmetic Slices](https://leetcode.com/problems/arithmetic-slices/) | [JavaScript](./src/arithmetic-slices/res.js)|Medium|
140-
|416|[Partition Equal Subset Sum](https://leetcode.com/problems/partition-equal-subset-sum/) | [JavaScript](./src/partition-equal-subset-sum/res.js)|Medium|
141-
|424|[Longest Repeating Character Replacement](https://leetcode.com/problems/longest-repeating-character-replacement/) | [JavaScript](./src/longest-repeating-character-replacement/res.js)|Medium|
142-
|434|[Number of Segments in a String](https://leetcode.com/problems/number-of-segments-in-a-string/) | [JavaScript](./src/number-of-segments-in-a-string/res.js)|Easy|
143-
|486|[Predict the Winner](https://leetcode.com/problems/predict-the-winner/) | [JavaScript](./src/predict-the-winner/res.js)|Medium|
144-
|494|[Target Sum](https://leetcode.com/problems/target-sum/) | [JavaScript](./src/target-sum/res.js)|Medium|
145-
|516|[Longest Palindromic Subsequence](https://leetcode.com/problems/longest-palindromic-subsequence/) | [JavaScript](./src/longest-palindromic-subsequence/res.js)|Medium|
146-
|523|[Continuous Subarray Sum](https://leetcode.com/problems/continuous-subarray-sum/) | [JavaScript](./src/continuous-subarray-sum/res.js)|Medium|
147-
|539|[Minimum Time Difference](https://leetcode.com/problems/minimum-time-difference/) | [JavaScript](./src/minimum-time-difference/res.js)|Medium|
148-
|687|[Longest Univalue Path](https://leetcode.com/problems/longest-univalue-path/) | [JavaScript](./src/longest-univalue-path/res.js)|Easy|
149-
|779|[K-th Symbol in Grammar](https://leetcode.com/problems/k-th-symbol-in-grammar/) | [JavaScript](./src/k-th-symbol-in-grammar/res.js)|Medium|
9+
| ID | Title | Solution | Difficulty |
10+
|-----|-------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------|------------|
11+
| 1 | [Two Sum](https://leetcode.com/problems/two-sum/) | [JavaScript](./src/two-sum/res.js) | Easy |
12+
| 2 | [Add Two Numbers](https://leetcode.com/problems/add-two-numbers/) | [JavaScript](./src/add-two-numbers/res.js) | Medium |
13+
| 3 | [Longest Substring Without Repeating Characters](https://leetcode.com/problems/longest-substring-without-repeating-characters/) | [JavaScript](./src/longest-substring-without-repeating-characters/res.js) | Medium |
14+
| 4 | [Median of Two Sorted Arrays](https://leetcode.com/problems/median-of-two-sorted-arrays/) | [JavaScript](./src/median-of-two-sorted-arrays/res.js) | Hard |
15+
| 5 | [Longest Palindromic Substring](https://leetcode.com/problems/longest-palindromic-substring/) | [JavaScript](./src/longest-palindromic-substring/res.js) | Medium |
16+
| 6 | [ZigZag Conversion](https://leetcode.com/problems/zigzag-conversion/) | [JavaScript](./src/zigzag-conversion/res.js) | Medium |
17+
| 7 | [Reverse Integer](https://leetcode.com/problems/reverse-integer/) | [JavaScript](./src/reverse-integer/res.js) | Easy |
18+
| 8 | [String to Integer (atoi)](https://leetcode.com/problems/string-to-integer-atoi/) | [JavaScript](./src/string-to-integer-atoi/res.js) | Medium |
19+
| 11 | [Container With Most Water](https://leetcode.com/problems/container-with-most-water/) | [JavaScript](./src/container-with-most-water/res.js) | Medium |
20+
| 13 | [Roman to Integer](https://leetcode.com/problems/roman-to-integer/) | [JavaScript](./src/roman-to-integer/res.js) | Easy |
21+
| 14 | [Longest Common Prefix](https://leetcode.com/problems/longest-common-prefix/) | [JavaScript](./src/longest-common-prefix/res.js) | Easy |
22+
| 15 | [3Sum](https://leetcode.com/problems/3sum/) | [JavaScript](./src/3sum/res.js) | Medium |
23+
| 16 | [3Sum Closest](https://leetcode.com/problems/3sum-closest/) | [JavaScript](./src/3sum-closest/res.js) | Medium |
24+
| 17 | [Letter Combinations of a Phone Number](https://leetcode.com/problems/letter-combinations-of-a-phone-number/) | [JavaScript](./src/letter-combinations-of-a-phone-number/res.js) | Medium |
25+
| 19 | [Remove Nth Node From End of List](https://leetcode.com/problems/remove-nth-node-from-end-of-list/) | [JavaScript](./src/remove-nth-node-from-end-of-list/res.js) | Medium |
26+
| 22 | [Generate Parentheses](https://leetcode.com/problems/generate-parentheses/) | [JavaScript](./src/generate-parentheses/res.js) | Medium |
27+
| 26 | [Remove Duplicates from Sorted Array](https://leetcode.com/problems/remove-duplicates-from-sorted-array/) | [JavaScript](./src/remove-duplicates-from-sorted-array/res.js) | Easy |
28+
| 27 | [Remove Element](https://leetcode.com/problems/remove-element/) | [JavaScript](./src/remove-element/res.js) | Easy |
29+
| 28 | [Implement strStr()](https://leetcode.com/problems/implement-strstr/) | [JavaScript](./src/implement-strstr/res.js) | Easy |
30+
| 29 | [Divide Two Integers](https://leetcode.com/problems/divide-two-integers/) | [JavaScript](./src/divide-two-integers/res.js) | Medium |
31+
| 33 | [Search in Rotated Sorted Array](https://leetcode.com/problems/search-in-rotated-sorted-array/) | [JavaScript](./src/search-in-rotated-sorted-array/res.js) | Medium |
32+
| 34 | [Search for a Range](https://leetcode.com/problems/search-for-a-range/) | [JavaScript](./src/search-for-a-range/res.js) | Medium |
33+
| 35 | [Search Insert Position](https://leetcode.com/problems/search-insert-position/) | [JavaScript](./src/search-insert-position/res.js) | Easy |
34+
| 39 | [Combination Sum](https://leetcode.com/problems/combination-sum/) | [JavaScript](./src/combination-sum/res.js) | Medium |
35+
| 40 | [Combination Sum II](https://leetcode.com/problems/combination-sum-ii/) | [JavaScript](./src/combination-sum-ii/res.js) | Medium |
36+
| 41 | [First Missing Positive](https://leetcode.com/problems/first-missing-positive/description/) | [JavaScript](./src/first-missing-positive/res.js) | Hard |
37+
| 42 | [ Trapping Rain Water](https://leetcode.com/problems/trapping-rain-water/description/) | [JavaScript](./src/trapping-rain-water/res.js) | Hard |
38+
| 43 | [Multiply Strings](https://leetcode.com/problems/multiply-strings/) | [JavaScript](./src/multiply-strings/res.js) | Medium |
39+
| 45 | [Jump Game II](https://leetcode.com/problems/jump-game-ii/) | [JavaScript](./src/jump-game-ii/res.js) | Hard |
40+
| 46 | [Permutations](https://leetcode.com/problems/permutations/) | [JavaScript](./src/permutations/res.js) | Medium |
41+
| 48 | [Rotate Image](https://leetcode.com/problems/rotate-image/) | [JavaScript](./src/rotate-image/res.js) | Medium |
42+
| 49 | [Group Anagrams](https://leetcode.com/problems/anagrams/) | [JavaScript](./src/anagrams/res.js) | Medium |
43+
| 53 | [Maximum Subarray](https://leetcode.com/problems/maximum-subarray/) | [JavaScript](./src/maximum-subarray/res.js) | Easy |
44+
| 54 | [Spiral Matrix](https://leetcode.com/problems/spiral-matrix/) | [JavaScript](./src/spiral-matrix/res.js) | Medium |
45+
| 55 | [Jump Game](https://leetcode.com/problems/jump-game/) <sup>*</sup> | [JavaScript](./src/jump-game/res.js) | Medium |
46+
| 56 | [Merge Intervals](https://leetcode.com/problems/merge-intervals/) | [JavaScript](./src/merge-intervals/res.js) | Medium |
47+
| 57 | [Insert Interval](https://leetcode.com/problems/insert-interval/) | [JavaScript](./src/insert-interval/res.js) | Hard |
48+
| 62 | [Unique Paths](https://leetcode.com/problems/unique-paths/) | [JavaScript](./src/unique-paths/res.js) | Medium |
49+
| 63 | [Unique Paths ii](https://leetcode.com/problems/unique-paths-ii/) | [JavaScript](./src/unique-paths-ii/res.js) | Medium |
50+
| 66 | [Plus One](https://leetcode.com/problems/plus-one/) | [JavaScript](./src/plus-one/res.js) | Easy |
51+
| 69 | [Sqrt(x)](https://leetcode.com/problems/sqrtx/) | [JavaScript](./src/sqrtx/res.js) | Easy |
52+
| 71 | [Simplify Path](https://leetcode.com/problems/simplify-path/) | [JavaScript](./src/simplify-path/res.js) | Medium |
53+
| 73 | [Set Matrix Zeroes](https://leetcode.com/problems/set-matrix-zeroes/) | [JavaScript](./src/set-matrix-zeroes/res.js) | Medium |
54+
| 75 | [Sort Colors](https://leetcode.com/problems/sort-colors/) | [JavaScript](./src/sort-colors/res.js) | Medium |
55+
| 80 | [Remove Duplicates from Sorted Array II](https://leetcode.com/problems/remove-duplicates-from-sorted-array-ii/) | [JavaScript](./src/remove-duplicates-from-sorted-array-ii/res.js) | Medium |
56+
| 81 | [Search in Rotated Sorted Array II](https://leetcode.com/problems/search-in-rotated-sorted-array-ii/) | [JavaScript](./src/search-in-rotated-sorted-array-ii/res.js) | Medium |
57+
| 88 | [ Merge Sorted Array](https://leetcode.com/problems/merge-sorted-array/) | [JavaScript](./src/merge-sorted-array/res.js) | Medium |
58+
| 91 | [Decode Ways](https://leetcode.com/problems/decode-ways/) | [JavaScript](./src/decode-ways/res.js) | Medium |
59+
| 93 | [Restore IP Addresses](https://leetcode.com/problems/restore-ip-addresses/) | [JavaScript](./src/restore-ip-addresses/res.js) | Medium |
60+
| 94 | [Binary Tree Inorder Traversal](https://leetcode.com/problems/binary-tree-inorder-traversal/) | [TypeScript](./src/binary-tree-inorder-traversal/res.ts) | Easy |
61+
| 98 | [Validate Binary Search Tree](https://leetcode.com/problems/validate-binary-search-tree/) | [JavaScript](./src/validate-binary-search-tree/res.js) | Medium |
62+
| 100 | [Same Tree](https://leetcode.com/problems/same-tree/) | [JavaScript](./src/same-tree/res.js) | Easy |
63+
| 101 | [Symmetric Tree](https://leetcode.com/problems/symmetric-tree/) | [JavaScript](./src/symmetric-tree/res.js) | Easy |
64+
| 102 | [Binary Tree Level Order Traversal](https://leetcode.com/problems/binary-tree-level-order-traversal/) | [JavaScript](./src/binary-tree-level-order-traversal/res.js) | Medium |
65+
| 104 | [Maximum Depth of Binary Tree](https://leetcode.com/problems/maximum-depth-of-binary-tree/) | [JavaScript](./src/maximum-depth-of-binary-tree/res.js) | Easy |
66+
| 107 | [Binary Tree Level Order Traversal II](https://leetcode.com/problems/binary-tree-level-order-traversal-ii/) | [JavaScript](./src/binary-tree-level-order-traversal-ii/res.js) | Easy |
67+
| 108 | [Convert Sorted Array to Binary Search Tree](https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree/) | [JavaScript](./src/convert-sorted-array-to-binary-search-tree/res.js) | Easy |
68+
| 111 | [Minimum Depth of Binary Tree](https://leetcode.com/problems/minimum-depth-of-binary-tree/) | [JavaScript](./src/minimum-depth-of-binary-tree/res.js) | Easy |
69+
| 120 | [Triangle](https://leetcode.com/problems/triangle/) | [JavaScript](./src/triangle/res.js) | Medium |
70+
| 121 | [Best Time to Buy and Sell Stock](https://leetcode.com/problems/best-time-to-buy-and-sell-stock/) | [JavaScript](./src/best-time-to-buy-and-sell-stock/res.js) | Easy |
71+
| 122 | [Best Time to Buy and Sell Stock II](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/) | [JavaScript](./src/best-time-to-buy-and-sell-stock-ii/res.js) | Easy |
72+
| 123 | [Best Time to Buy and Sell Stock III](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iii/) <sup>*</sup> | [JavaScript](./src/best-time-to-buy-and-sell-stock-iii/res.js) | Hard |
73+
| 127 | [Word Ladder](https://leetcode.com/problems/word-ladder/) | [JavaScript](./src/word-ladder/res.js) | Medium |
74+
| 128 | [Longest Consecutive Sequence](https://leetcode.com/problems/longest-consecutive-sequence/) | [JavaScript](./src/longest-consecutive-sequence/res.js) | Medium |
75+
| 130 | [Surrounded Regions](https://leetcode.com/problems/surrounded-regions/) | [JavaScript](./src/surrounded-regions/res.js) | Medium |
76+
| 133 | [Clone Graph](https://leetcode.com/problems/clone-graph/) | [JavaScript](./src/clone-graph/res.js) | Medium |
77+
| 134 | [Gas Station](https://leetcode.com/problems/gas-station/) | [JavaScript](./src/gas-station/res.js) | Medium |
78+
| 135 | [Candy](https://leetcode.com/problems/candy/) | [JavaScript](./src/candy/res.js) | Hard |
79+
| 136 | [Single Number](https://leetcode.com/problems/single-number/) | [JavaScript](./src/single-number/res.js) | Easy |
80+
| 137 | [Single Number II](https://leetcode.com/problems/single-number-ii/) | [JavaScript](./src/single-number-ii/res.js) | Medium |
81+
| 151 | [Reverse Words in a String](https://leetcode.com/problems/reverse-words-in-a-string/) | [JavaScript](./src/reverse-words-in-a-string/res.js) | Medium |
82+
| 152 | [Maximum Product Subarray](https://leetcode.com/problems/maximum-product-subarray/) | [JavaScript](./src/maximum-product-subarray/res.js) | Medium |
83+
| 153 | [Find Minimum in Rotated Sorted Array](https://leetcode.com/problems/find-minimum-in-rotated-sorted-array/) | [JavaScript](./src/find-minimum-in-rotated-sorted-array/res.js) | Medium |
84+
| 154 | [Find Minimum in Rotated Sorted Array II](https://leetcode.com/problems/find-minimum-in-rotated-sorted-array-ii/) | [JavaScript](./src/find-minimum-in-rotated-sorted-array-ii/res.js) | Medium |
85+
| 162 | [Find Peak Element](https://leetcode.com/problems/find-peak-element/) | [JavaScript](./src/find-peak-element/res.js) | Medium |
86+
| 164 | [Maximum Gap](https://leetcode.com/problems/maximum-gap/) | [JavaScript](./src/maximum-gap/res.js) | Hard |
87+
| 165 | [Compare Version Numbers](https://leetcode.com/problems/compare-version-numbers/) | [JavaScript](./src/compare-version-numbers/res.js) | Medium |
88+
| 169 | [Majority Element](https://leetcode.com/problems/majority-element/) | [JavaScript](./src/majority-element/res.js) | Easy |
89+
| 175 | [Combine Two Tables](https://leetcode.com/problems/combine-two-tables/) | [SQL](./src/combine-two-tables/res.txt) | Easy |
90+
| 176 | [Second Highest Salary](https://leetcode.com/problems/second-highest-salary/) | [SQL](./src/second-highest-salary/res.txt) | Easy |
91+
| 177 | [Nth Highest Salary](https://leetcode.com/problems/nth-highest-salary/) | [SQL](./src/nth-highest-salary/res.txt) | Medium |
92+
| 181 | [Employees Earning More Than Their Managers](https://leetcode.com/problems/employees-earning-more-than-their-managers/) | [SQL](./src/employees-earning-more-than-their-managers/res.txt) | Easy |
93+
| 182 | [Duplicate Emails](https://leetcode.com/problems/duplicate-emails/) | [SQL](./src/duplicate-emails/res.txt) | Easy |
94+
| 183 | [Customers Who Never Order](https://leetcode.com/problems/customers-who-never-order/) | [SQL](./src/customers-who-never-order/res.txt) | Easy |
95+
| 184 | [Department Highest Salary](https://leetcode.com/problems/department-highest-salary/) | [SQL](./src/department-highest-salary/res.txt) | Medium |
96+
| 188 | [Best Time to Buy and Sell Stock IV](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iv/) | [JavaScript](./src/best-time-to-buy-and-sell-stock-iv/res.txt) | Hard |
97+
| 189 | [Rotate Array](https://leetcode.com/problems/rotate-array/) | [JavaScript](./src/rotate-array/res.js) | Easy |
98+
| 190 | [Reverse Bits](https://leetcode.com/problems/reverse-bits/) | [JavaScript](./src/reverse-bits/res.js) | Easy |
99+
| 196 | [Delete Duplicate Emails](https://leetcode.com/problems/delete-duplicate-emails/) | [SQL](./src/delete-duplicate-emails/res.txt) | Easy |
100+
| 197 | [Rising Temperature](https://leetcode.com/problems/rising-temperature/) | [SQL](./src/rising-temperature/res.txt) | Easy |
101+
| 206 | [Reverse Linked List](https://leetcode.com/problems/reverse-linked-list/) | [JavaScript](./src/reverse-linked-list/res.js) | Easy |
102+
| 207 | [Course Schedule](https://leetcode.com/problems/course-schedule/) | [JavaScript](./src/course-schedule/res.js) | Medium |
103+
| 209 | [Minimum Size Subarray Sum](https://leetcode.com/problems/minimum-size-subarray-sum/) | [JavaScript](./src/minimum-size-subarray-sum/res.js) | Medium |
104+
| 210 | [Course Schedule II](https://leetcode.com/problems/course-schedule-ii/) | [JavaScript](./src/course-schedule-ii/res.js) | Medium |
105+
| 215 | [Kth Largest Element in an Array](https://leetcode.com/problems/kth-largest-element-in-an-array/) | [JavaScript](./src/kth-largest-element-in-an-array/res.js) | Medium |
106+
| 217 | [Contains Duplicate](https://leetcode.com/problems/contains-duplicate/) | [JavaScript](./src/contains-duplicate/res.js) | Easy |
107+
| 219 | [Contains Duplicate II](https://leetcode.com/problems/contains-duplicate-ii/) | [JavaScript](./src/contains-duplicate-ii/res.js) | Easy |
108+
| 220 | [Contains Duplicate III](https://leetcode.com/problems/contains-duplicate-iii/) | [JavaScript](./src/contains-duplicate-iii/res.js) | Medium |
109+
| 228 | [Summary Ranges](https://leetcode.com/problems/summary-ranges/solution/) | [JavaScript](./src/summary-ranges/res.js) | Medium |
110+
| 238 | [Product of Array Except Self](https://leetcode.com/problems/product-of-array-except-self/solution/) | [JavaScript](./src/product-of-array-except-self/res.js) | Medium |
111+
| 239 | [Sliding Window Maximum](https://leetcode.com/problems/sliding-window-maximum/description/) | [JavaScript](./src/sliding-window-maximum/description/res.js) | Hard |
112+
| 240 | [Search a 2D Matrix II](https://leetcode.com/problems/search-a-2d-matrix-ii/) | [JavaScript](./src/search-a-2d-matrix-ii/res.js) | Medium |
113+
| 274 | [H-Index](https://leetcode.com/problems/h-index/) | [JavaScript](./src/h-index/res.js) | Medium |
114+
| 275 | [H-Index II](https://leetcode.com/problems/h-index-ii/) | [JavaScript](./src/h-index-ii/res.js) | Medium |
115+
| 278 | [First Bad Version](https://leetcode.com/problems/first-bad-version/) | [JavaScript](./src/first-bad-version/res.js) | Easy |
116+
| 283 | [Move Zeroes](https://leetcode.com/problems/move-zeroes/) | [JavaScript](./src/move-zeroes/res.js) | Easy |
117+
| 287 | [Find the Duplicate Number](https://leetcode.com/problems/find-the-duplicate-number/) | [JavaScript](./src/find-the-duplicate-number/res.js) | Medium |
118+
| 289 | [Game of Life](https://leetcode.com/problems/game-of-life/) | [JavaScript](./src/game-of-life/res.js) | Medium |
119+
| 295 | [Find Median from Data Stream](https://leetcode.com/problems/find-median-from-data-stream/) | [JavaScript](./src/find-median-from-data-stream/res.js) | Hard |
120+
| 299 | [Bulls and Cows](https://leetcode.com/problems/bulls-and-cows/) | [JavaScript](./src/bulls-and-cows/res.js) | Medium |
121+
| 300 | [Longest Increasing Subsequence](https://leetcode.com/problems/longest-increasing-subsequence/) | [JavaScript](./src/longest-increasing-subsequence/res.js) | Medium |
122+
| 307 | [Range Sum Query - Mutable](https://leetcode.com/problems/range-sum-query-mutable/) | [JavaScript](./src/range-sum-query-mutable/res.js) | Medium |
123+
| 309 | [Best Time to Buy and Sell Stock with Cooldown](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-cooldown/) | [JavaScript](./src/best-time-to-buy-and-sell-stock-with-cooldown/res.js) | Medium |
124+
| 310 | [Minimum Height Trees](https://leetcode.com/problems/minimum-height-trees/) | [JavaScript](./src/minimum-height-trees/res.js) | Medium |
125+
| 315 | [Count of Smaller Numbers After Self](https://leetcode.com/problems/count-of-smaller-numbers-after-self/) <sup>*</sup> | [JavaScript](./src/count-of-smaller-numbers-after-self/res.js) | Hard |
126+
| 322 | [Coin Change](https://leetcode.com/problems/coin-change/) | [JavaScript](./src/coin-change/res.js) | Medium |
127+
| 327 | [Count of Range Sum](https://leetcode.com/problems/count-of-range-sum/) | [JavaScript](./src/count-of-range-sum/res.js) | Hard |
128+
| 334 | [Increasing Triplet Subsequence](https://leetcode.com/problems/increasing-triplet-subsequence/) | [JavaScript](./src/increasing-triplet-subsequence/res.js) | Medium |
129+
| 340 | [Longest Substring with At Most K Distinct Characters](https://leetcode.com/problems/longest-substring-with-at-most-k-distinct-characters/) | [JavaScript](./src/longest-substring-with-at-most-k-distinct-characters/res.js) | Hard |
130+
| 342 | [Power of Four](https://leetcode.com/problems/power-of-four/) | [JavaScript](./src/power-of-four/res.js) | Easy |
131+
| 344 | [Reverse String](https://leetcode.com/problems/reverse-string/) | [JavaScript](./src/reverse-string/res.js) | Easy |
132+
| 349 | [Intersection of Two Arrays](https://leetcode.com/problems/intersection-of-two-arrays/) | [JavaScript](./src/intersection-of-two-arrays/res.js) | Easy |
133+
| 350 | [Intersection of Two Arrays ii](https://leetcode.com/problems/intersection-of-two-arrays-ii/) | [JavaScript](./src/intersection-of-two-arrays-ii/res.js) | Easy |
134+
| 371 | [Sum of Two Integers](https://leetcode.com/problems/sum-of-two-integers/) | [JavaScript](./src/sum-of-two-integers/res.js) | Easy |
135+
| 374 | [Guess Number Higher or Lower](https://leetcode.com/problems/guess-number-higher-or-lower/) | [JavaScript](./src/guess-number-higher-or-lower/res.py) | Easy |
136+
| 376 | [Wiggle Subsequence](https://leetcode.com/problems/wiggle-subsequence/) | [JavaScript](./src/wiggle-subsequence/res.js) | Medium |
137+
| 384 | [Shuffle an Array](https://leetcode.com/problems/shuffle-an-array/) | [JavaScript](./src/shuffle-an-array/res.js) | Medium |
138+
| 395 | [Longest Substring with At Least K Repeating Characters](https://leetcode.com/problems/longest-substring-with-at-least-k-repeating-characters/) | [JavaScript](./src/longest-substring-with-at-least-k-repeating-characters/res.js) | Medium |
139+
| 404 | [Sum of Left Leaves](https://leetcode.com/problems/sum-of-left-leaves/) | [JavaScript](./src/sum-of-left-leaves/res.js) | Easy |
140+
| 413 | [Arithmetic Slices](https://leetcode.com/problems/arithmetic-slices/) | [JavaScript](./src/arithmetic-slices/res.js) | Medium |
141+
| 416 | [Partition Equal Subset Sum](https://leetcode.com/problems/partition-equal-subset-sum/) | [JavaScript](./src/partition-equal-subset-sum/res.js) | Medium |
142+
| 424 | [Longest Repeating Character Replacement](https://leetcode.com/problems/longest-repeating-character-replacement/) | [JavaScript](./src/longest-repeating-character-replacement/res.js) | Medium |
143+
| 434 | [Number of Segments in a String](https://leetcode.com/problems/number-of-segments-in-a-string/) | [JavaScript](./src/number-of-segments-in-a-string/res.js) | Easy |
144+
| 486 | [Predict the Winner](https://leetcode.com/problems/predict-the-winner/) | [JavaScript](./src/predict-the-winner/res.js) | Medium |
145+
| 494 | [Target Sum](https://leetcode.com/problems/target-sum/) | [JavaScript](./src/target-sum/res.js) | Medium |
146+
| 516 | [Longest Palindromic Subsequence](https://leetcode.com/problems/longest-palindromic-subsequence/) | [JavaScript](./src/longest-palindromic-subsequence/res.js) | Medium |
147+
| 523 | [Continuous Subarray Sum](https://leetcode.com/problems/continuous-subarray-sum/) | [JavaScript](./src/continuous-subarray-sum/res.js) | Medium |
148+
| 539 | [Minimum Time Difference](https://leetcode.com/problems/minimum-time-difference/) | [JavaScript](./src/minimum-time-difference/res.js) | Medium |
149+
| 687 | [Longest Univalue Path](https://leetcode.com/problems/longest-univalue-path/) | [JavaScript](./src/longest-univalue-path/res.js) | Easy |
150+
| 779 | [K-th Symbol in Grammar](https://leetcode.com/problems/k-th-symbol-in-grammar/) | [JavaScript](./src/k-th-symbol-in-grammar/res.js) | Medium |
151+
| NO | [NAME](https://leetcode.com/problems/XXX/) | [TypeScript](./src/XXX/res.ts) | Easy |
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/**
2+
* Definition for a binary tree node.
3+
*/
4+
class TreeNode {
5+
val: number
6+
left: TreeNode | null
7+
right: TreeNode | null
8+
constructor(val?: number, left?: TreeNode | null, right?: TreeNode | null) {
9+
this.val = (val===undefined ? 0 : val)
10+
this.left = (left===undefined ? null : left)
11+
this.right = (right===undefined ? null : right)
12+
}
13+
}
14+
15+
/**
16+
* 递归
17+
* @param root
18+
*/
19+
function inorderTraversal(root: TreeNode | null): number[] {
20+
const result: number[] = [];
21+
22+
if (!root) {
23+
return result;
24+
}
25+
26+
if (root.left) {
27+
result.push(...inorderTraversal(root.left));
28+
}
29+
result.push(root.val);
30+
if (root.right) {
31+
result.push(...inorderTraversal(root.right));
32+
}
33+
34+
return result;
35+
};
36+
37+
/**
38+
* 迭代
39+
* @param root
40+
*/
41+
function inorderTraversal2(root: TreeNode | null): number[] {
42+
const result: number[] = [];
43+
44+
if (!root) {
45+
return result;
46+
}
47+
48+
const nodes = [];
49+
50+
let currentPointer = root;
51+
while(nodes.length || currentPointer) {
52+
// left
53+
while (currentPointer) {
54+
nodes.push(currentPointer);
55+
currentPointer = currentPointer.left;
56+
}
57+
const singleNode = nodes.pop();
58+
result.push(singleNode.val);
59+
60+
// right
61+
currentPointer = singleNode.right;
62+
}
63+
64+
return result;
65+
};

0 commit comments

Comments
 (0)
Please sign in to comment.