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
+2
Original file line number
Diff line number
Diff line change
@@ -153,6 +153,7 @@ Also, there are open source implementations for basic data structs and algorithm
153
153
| 482 |[License Key Formatting](https://leetcode.com/problems/license-key-formatting/)|[Python](https://github.com/qiyuangong/leetcode/blob/master/python/482_License_Key_Formatting.py)[Java](https://github.com/qiyuangong/leetcode/blob/master/java/482_License_Key_Formatting.java)| String processing, lower and len % K, O(n) and O(n) |
154
154
| 538 |[Convert BST to Greater Tree](https://leetcode.com/problems/convert-bst-to-greater-tree/description/)|[Python](https://github.com/qiyuangong/leetcode/blob/master/python/538_Convert_BST_to_Greater_Tree.py)[Java](https://github.com/qiyuangong/leetcode/blob/master/java/538_Convert_BST_to_Greater_Tree.java)| Right first DFS with a variable recording sum of node.val and right.val. 1. Recursive.<br>2. Stack 3. Reverse Morris In-order Traversal |
155
155
| 543 |[Diameter of Binary Tree](https://leetcode.com/problems/diameter-of-binary-tree/description/)|[Python](https://github.com/qiyuangong/leetcode/blob/master/python/543_Diameter_of_Binary_Tree.py)[Java](https://github.com/qiyuangong/leetcode/blob/master/java/543_Diameter_of_Binary_Tree.java)| DFS with O(1) for max answer |
156
+
| 547 |[Friend Circles](https://leetcode.com/problems/friend-circles/)|[Python](https://github.com/qiyuangong/leetcode/blob/master/python/547_Friend_Circles.py)[Java](https://github.com/qiyuangong/leetcode/blob/master/java/547_Friend_Circles.java)| 1. DFS, O(n^2) and O(1)<br>2. BFS, O(n^2) and O(1)<br>3. Union-find, |
156
157
| 557 |[Reverse Words in a String III](https://leetcode.com/problems/reverse-words-in-a-string-iii/)|[Python](https://github.com/qiyuangong/leetcode/blob/master/python/557_Reverse_Words_in_a_String_III.py)[Java](https://github.com/qiyuangong/leetcode/blob/master/java/557_Reverse_Words_in_a_String_III.java)| String handle: Split with space than reverse word, O(n) and O(n). Better solution is that reverse can be O(1) space in array. |
157
158
| 560 |[Subarray Sum Equals K](https://leetcode.com/problems/subarray-sum-equals-k/)|[Python](https://github.com/qiyuangong/leetcode/blob/master/python/560_Subarray_Sum_Equals_K.py)[Java](https://github.com/qiyuangong/leetcode/blob/master/java/560_Subarray_Sum_Equals_K.java)| Note that there are n^2 possible pairs, so the key point is accelerate computation for sum and reduce unnecessary pair. 1. Cummulative sum, O(n^2) and O(1)/O(n)<br>2. Add sum into hash, check if sum - k is in hash, O(n) and O(n) |
158
159
| 572 |[Subtree of Another Tree](https://leetcode.com/problems/subtree-of-another-tree/description/)|[Python](https://github.com/qiyuangong/leetcode/blob/master/python/572_Subtree_of_Another_Tree.py)[Java](https://github.com/qiyuangong/leetcode/blob/master/java/572_Subtree_of_Another_Tree.java)| 1. Tree traverse and compare<br>2. Tree to string and compare |
@@ -163,6 +164,7 @@ Also, there are open source implementations for basic data structs and algorithm
| 680 |[Valid Palindrome II](https://leetcode.com/problems/valid-palindrome-ii/)|[Python](https://github.com/qiyuangong/leetcode/blob/master/python/680_Valid_Palindrome_II.py)[Java](https://github.com/qiyuangong/leetcode/blob/master/java/680_Valid_Palindrome_II.java)| Recursively check s[left == end, when not equal delete left or right. |
165
166
| 692 |[Top K Frequent Words](https://leetcode.com/problems/top-k-frequent-words/)|[Python](https://github.com/qiyuangong/leetcode/blob/master/python/692_Top_K_Frequent_Words.py)[Java](https://github.com/qiyuangong/leetcode/blob/master/java/692_Top_K_Frequent_Words.java)| 1. Sort based on frequency and alphabetical order, O(nlgn) and O(n)<br>2. Find top k with Heap, O(nlogk) and O(n) |
167
+
| 695 |[Max Area of Island](https://leetcode.com/problems/max-area-of-island/)|[Python](https://github.com/qiyuangong/leetcode/blob/master/python/695_Max_Area_of_Island.py)[Java](https://github.com/qiyuangong/leetcode/blob/master/java/695_Max_Area_of_Island.java)| 1. DFS, O(n^2) and O(n)<br>2. BFS, O(n^2) and O(n)|
166
168
| 697 |[Degree of an Array](https://leetcode.com/problems/degree-of-an-array/)|[Python](https://github.com/qiyuangong/leetcode/blob/master/python/697_Degree_of_an_Array.py)[Java](https://github.com/qiyuangong/leetcode/blob/master/java/697_Degree_of_an_Array.java)| 1. Find degree and value, then find smallest subarray (start and end with this value), O(n) and O(n)<br>2. Go through nums, remember left most pos and right most for each value, O(n) and O(n) |
167
169
| 703 |[Kth Largest Element in a Stream](https://leetcode.com/problems/kth-largest-element-in-a-stream/)|[Python](https://github.com/qiyuangong/leetcode/blob/master/python/703_Kth_Largest_Element_in_a_Stream.py)[Java](https://github.com/qiyuangong/leetcode/blob/master/java/703_Kth_Largest_Element_in_a_Stream.java)| 1. Sort and insert into right place, O(nlgn) and O(n)<br>2. k largest heap, O(nlogk) and O(n) |
168
170
| 706 |[Design HashMap](https://leetcode.com/problems/design-hashmap/)|[Python](https://github.com/qiyuangong/leetcode/blob/master/python/706_Design_HashMap.py)[Java](https://github.com/qiyuangong/leetcode/blob/master/java/706_Design_HashMap.java)| Hash implementation, mod is fine. Be careful about key conflict and key remove. |
0 commit comments