Skip to content

Commit 76f2d48

Browse files
clean up
1 parent 97e5a4d commit 76f2d48

File tree

13 files changed

+154
-210
lines changed

13 files changed

+154
-210
lines changed

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ Your ideas/fixes/algorithms are more than welcome!
247247
|236|[Lowest Common Ancestor of a Binary Tree](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree/)|[Solution](../master/src/main/java/com/stevesun/solutions/_236.java)| O(n)|O(h) | Medium| DFS
248248
|235|[Lowest Common Ancestor of a Binary Search Tree](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree/)|[Solution](../master/src/main/java/com/stevesun/solutions/_235.java)| O(h)|O(1) | Easy| DFS
249249
|233|[Number of Digit One](https://leetcode.com/problems/number-of-digit-one/)|[Solution](../master/src/main/java/com/stevesun/solutions/NumberofDigitOne.java)| O(n)|O(1) | Hard| Math
250+
|232|[Implement Queue using Stacks](https://leetcode.com/problems/implement-queue-using-stacks/)|[Solution](../master/src/main/java/com/stevesun/solutions/_232.java)| O(n)|O(n) | Medium| Stack, Design
250251
|229|[Majority Element II](https://leetcode.com/problems/majority-element-ii/)|[Solution](../master/src/main/java/com/stevesun/solutions/MajorityElementII.java)| O(n)|O(n) | Medium|
251252
|228|[Summary Ranges](https://leetcode.com/problems/summary-ranges/)|[Solution](../master/src/main/java/com/stevesun/solutions/SummaryRanges.java)| O(n)|O(1) | Medium| Array
252253
|226|[Invert Binary Tree](https://leetcode.com/problems/invert-binary-tree/)|[Solution](../master/src/main/java/com/stevesun/solutions/InvertBinaryTree.java)| O(n)|O(h) | Easy| DFS, recursion
@@ -272,6 +273,7 @@ Your ideas/fixes/algorithms are more than welcome!
272273
|201|[Bitwise AND of Numbers Range](https://leetcode.com/problems/bitwise-and-of-numbers-range/)|[Solution](../master/src/main/java/com/stevesun/solutions/_201.java)| O(min(m,n))|O(1) | Medium | Bit Manipulation
273274
|200|[Number of Islands](https://leetcode.com/problems/number-of-islands/)|[Union Find](../master/src/main/java/com/stevesun/solutions/_200UnionFind.java) [DFS](../master/MEDIUM/src/medium/_200DFS.java)| O(m*n)|O(m*n) | Medium| Union Find, DFS
274275
|198|[House Robber](https://leetcode.com/problems/house-robber/)|[Solution](../master/src/main/java/com/stevesun/solutions/HouseRobber.java)| O(n)|O(n)| Easy | DP
276+
|191|[Number of 1 Bits](https://leetcode.com/problems/number-of-1-bits/)|[Solution](../master/src/main/java/com/stevesun/solutions/_191.java)| O(n)|O(1)| Easy | Bit Manipulation
275277
|190|[Reverse Bits](https://leetcode.com/problems/reverse-bits/)|[Solution](../master/src/main/java/com/stevesun/solutions/ReverseBits.java)| O(n)|O(1)| Easy | Bit Manipulation
276278
|189|[Rotate Array](https://leetcode.com/problems/rotate-array/)|[Solution](../master/src/main/java/com/stevesun/solutions/_189.java)| O(n)|O(n), could be optimized to O(1) | Easy
277279
|187|[Repeated DNA Sequences](https://leetcode.com/problems/repeated-dna-sequences/)|[Solution](../master/src/main/java/com/stevesun/solutions/_187.java)| O(n)|O(n) | Medium
@@ -290,7 +292,7 @@ Your ideas/fixes/algorithms are more than welcome!
290292
|163|[Missing Ranges](https://leetcode.com/problems/missing-ranges/)|[Solution](../master/src/main/java/com/stevesun/solutions/MissingRanges.java) | O(n) |O(1) | |
291293
|162|[Find Peak Element](https://leetcode.com/problems/find-peak-element/)|[Solution](../master/src/main/java/com/stevesun/solutions/FindPeakElement.java) | O(1) |O(logn)/O(n) | Binary Search|
292294
|161|[One Edit Distance](https://leetcode.com/problems/one-edit-distance/)|[Solution](../master/src/main/java/com/stevesun/solutions/OneEditDistance.java) | O(n) |O(1) | |
293-
|160|[Intersection of Two Linked Lists](https://leetcode.com/problems/intersection-of-two-linked-lists/)|[Solution](../master/src/main/java/com/stevesun/solutions/IntersectionofTwoLinkedLists.java)| O(m+n)|O(1) | Easy| Linked List
295+
|160|[Intersection of Two Linked Lists](https://leetcode.com/problems/intersection-of-two-linked-lists/)|[Solution](../master/src/main/java/com/stevesun/solutions/_160.java)| O(m+n)|O(1) | Easy| Linked List
294296
|159|[Longest Substring with At Most Two Distinct Characters](https://leetcode.com/problems/longest-substring-with-at-most-two-distinct-characters/)|[Solution](../master/src/main/java/com/stevesun/solutions/LongestSubstringwithAtMostTwoDistinctCharacters.java)| O(n)|O(1) | Hard| String, Sliding Window
295297
|158|[Read N Characters Given Read4 II - Call multiple times](https://leetcode.com/problems/read-n-characters-given-read4-ii-call-multiple-times/)|[Solution](../master/src/main/java/com/stevesun/solutions/ReadNCharactersGivenRead4IICallMultipleTimes.java)| O(n)|O(1) | Hard|
296298
|157|[Read N Characters Given Read4](https://leetcode.com/problems/read-n-characters-given-read4/)|[Solution](../master/src/main/java/com/stevesun/solutions/ReadNCharactersGivenRead4.java)| O(n)|O(1) | Easy|
@@ -339,7 +341,7 @@ Your ideas/fixes/algorithms are more than welcome!
339341
|105|[Construct Binary Tree from Preorder and Inorder Traversal](https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/)|[Solution](../master/src/main/java/com/stevesun/solutions/_105.java)| O(n)|O(n) | Medium| Recursion, Tree
340342
|104|[Maximum Depth of Binary Tree](https://leetcode.com/problems/maximum-depth-of-binary-tree/)|[Solution](../master/src/main/java/com/stevesun/solutions/MaximumDepthOfBinaryTree.java)| O(n)|O(h) | Easy| DFS
341343
|103|[Binary Tree Zigzag Level Order Traversal](https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/)|[Solution](../master/src/main/java/com/stevesun/solutions/_103.java)| O(n)|O(h) | Medium| BFS,DFS
342-
|102|[Binary Tree Level Order Traversal](https://leetcode.com/problems/binary-tree-level-order-traversal/)|[Solution](../master/src/main/java/com/stevesun/solutions/BinaryTreeLevelOrderTraversal.java)| O(n)|O(h) | Easy| BFS
344+
|102|[Binary Tree Level Order Traversal](https://leetcode.com/problems/binary-tree-level-order-traversal/)|[Solution](../master/src/main/java/com/stevesun/solutions/_102.java)| O(n)|O(h) | Medium| BFS
343345
|99|[Recover Binary Search Tree](https://leetcode.com/problems/recover-binary-search-tree/)|[Solution](../master/src/main/java/com/stevesun/solutions/RecoverBinarySearchTree.java) | O(?) | O(?) | Hard |
344346
|98|[Validate Binary Search Tree](https://leetcode.com/problems/validate-binary-search-tree/)|[Solution](../master/src/main/java/com/stevesun/solutions/_98.java) | O(n) | O(h) | Medium | DFS/Recursion
345347
|97|[Interleaving String](https://leetcode.com/problems/interleaving-string/)|[Solution](../master/src/main/java/com/stevesun/solutions/InterleavingString.java)| O(?)|O(?) | Hard| DP
@@ -364,7 +366,7 @@ Your ideas/fixes/algorithms are more than welcome!
364366
|74|[Search a 2D Matrix](https://leetcode.com/problems/search-a-2d-matrix/)|[Solution](../master/src/main/java/com/stevesun/solutions/Searcha2DMatrix.java)|O(logn)|O(1)|Medium| Binary Search
365367
|73|[Set Matrix Zeroes](https://leetcode.com/problems/set-matrix-zeroes/)|[Solution](../master/src/main/java/com/stevesun/solutions/_73.java)|O(mn)|O(mn)|Medium|
366368
|72|[Edit Distance](https://leetcode.com/problems/edit-distance/)|[Solution](../master/src/main/java/com/stevesun/solutions/EditDistance.java)|O(m*n)|O(m+n)|Hard|
367-
|71|[Simplify Path](https://leetcode.com/problems/simplify-path/)|[Solution](../master/src/main/java/com/stevesun/solutions/SimplifyPath.java)|O(n)|O(n)|Medium| Stack
369+
|71|[Simplify Path](https://leetcode.com/problems/simplify-path/)|[Solution](../master/src/main/java/com/stevesun/solutions/_71.java)|O(n)|O(n)|Medium| Stack
368370
|70|[Climbing Stairs](https://leetcode.com/problems/climbing-stairs/)|[Solution](../master/src/main/java/com/stevesun/solutions/ClimbingStairs.java)|O(n)|O(n)|Easy| DP
369371
|69|[Sqrt(x)](https://leetcode.com/problems/sqrtx/)|[Solution](../master/src/main/java/com/stevesun/solutions/Sqrt.java)|O(logn)|O(1)|Easy|
370372
|68|[Text Justification](https://leetcode.com/problems/text-justification/)|[Solution](../master/src/main/java/com/stevesun/solutions/TextJustification.java)|O(n)|O(1)|Hard|
@@ -395,16 +397,16 @@ Your ideas/fixes/algorithms are more than welcome!
395397
|36|[Valid Sudoku](https://leetcode.com/problems/valid-sudoku/)|[Solution](../master/src/main/java/com/stevesun/solutions/ValidSudoku.java)|O(?)|O(?)|Medium|
396398
|35|[Search Insert Position](https://leetcode.com/problems/search-insert-position/)|[Solution](../master/src/main/java/com/stevesun/solutions/SearchInsertPosition.java)|O(n)|O(1)|Medium|Array
397399
|34|[Search for a Range](https://leetcode.com/problems/search-for-a-range/)|[Solution](../master/src/main/java/com/stevesun/solutions/SearchForARange.java)|O(logn)|O(1)|Medium|Array, Binary Search
398-
|33|[Search in Rotated Sorted Array](https://leetcode.com/problems/search-in-rotated-sorted-array/)|[Solution](../master/src/main/java/com/stevesun/solutions/SearchinRotatedSortedArray.java)|O(logn)|O(1)|Hard|Binary Search
400+
|33|[Search in Rotated Sorted Array](https://leetcode.com/problems/search-in-rotated-sorted-array/)|[Solution](../master/src/main/java/com/stevesun/solutions/_33.java)|O(logn)|O(1)|Medium|Binary Search
399401
|32|[Longest Valid Parentheses](https://leetcode.com/problems/longest-valid-parentheses/)|[Solution](../master/src/main/java/com/stevesun/solutions/LongestValidParentheses.java)|O(n)|O(n)|Hard|Stack, DP
400402
|31|[Next Permutation](https://leetcode.com/problems/next-permutation)|[Solution](../master/src/main/java/com/stevesun/solutions/NextPermutation.java)|O(n)|O(1)|Medium|Array
401403
|30|[Substring with Concatenation of All Words](https://leetcode.com/problems/substring-with-concatenation-of-all-words/)|[Solution](../master/src/main/java/com/stevesun/solutions/SubstringwithConcatenationofAllWords.java)|O(n^2)|O(n)|Hard| HashMap
402404
|29|[Divide Two Integers](https://leetcode.com/problems/divide-two-integers/)|[Solution](../master/src/main/java/com/stevesun/solutions/DivideTwoIntegers.java)|O(?)|O(?)|Medium|
403405
|28|[Implement strStr()](https://leetcode.com/problems/implement-strstr/)|[Solution](../master/src/main/java/com/stevesun/solutions/ImplementStrStr.java)|O(n)|O(1)|Easy| String
404406
|27|[Remove Element](https://leetcode.com/problems/remove-element/)|[Solution](../master/src/main/java/com/stevesun/solutions/RemoveElement.java)|O(n)|O(1)| Easy |
405-
|26|[Remove Duplicates from Sorted Array](https://leetcode.com/problems/remove-duplicates-from-sorted-array/)|[Solution](../master/src/main/java/com/stevesun/solutions/RemoveDuplicatesFromSortedArray.java)|O(n)|O(1)|Easy|
407+
|26|[Remove Duplicates from Sorted Array](https://leetcode.com/problems/remove-duplicates-from-sorted-array/)|[Solution](../master/src/main/java/com/stevesun/solutions/_26.java)|O(n)|O(1)|Easy| Array
406408
|25|[Reverse Nodes in k-Group](https://leetcode.com/problems/reverse-nodes-in-k-group/)|[Solution](../master/src/main/java/com/stevesun/solutions/ReverseNodesinkGroup.java)|O(n)|O(1)| Hard | Recursion, LinkedList
407-
|24|[Swap Nodes in Pairs](https://leetcode.com/problems/swap-nodes-in-pairs/)|[Solution](../master/src/main/java/com/stevesun/solutions/SwapNodesinPairs.java)|O(n)|O(1)|Easy| Recursion, LinkedList
409+
|24|[Swap Nodes in Pairs](https://leetcode.com/problems/swap-nodes-in-pairs/)|[Solution](../master/src/main/java/com/stevesun/solutions/_24.java)|O(n)|O(h)|Medium| Recursion, LinkedList
408410
|23|[Merge k Sorted Lists](https://leetcode.com/problems/merge-k-sorted-lists/)|[Solution](../master/src/main/java/com/stevesun/solutions/MergeKSortedList.java)|O(n*logk)|O(logk)|Hard|Heap
409411
|22|[Generate Parentheses](https://leetcode.com/problems/generate-parentheses/)|[Solution](../master/src/main/java/com/stevesun/solutions/GenerateParentheses.java)|TBD|O(n)|Medium|Backtracking
410412
|21|[Merge Two Sorted Lists](https://leetcode.com/problems/merge-two-sorted-lists/)|[Solution](../master/src/main/java/com/stevesun/solutions/_21.java)|O(n)|O(h)|Easy| Recursion
@@ -423,7 +425,7 @@ Your ideas/fixes/algorithms are more than welcome!
423425
|8|[String to Integer (atoi)](https://leetcode.com/problems/string-to-integer-atoi/)|[Solution](../master/src/main/java/com/stevesun/solutions/_8.java)| O(n) | O(1) | Medium
424426
|7|[Reverse Integer](https://leetcode.com/problems/reverse-integer/)|[Solution](../master/src/main/java/com/stevesun/solutions/ReverseInteger.java) | O(1) | O(1) | Easy |
425427
|6|[ZigZag Conversion](https://leetcode.com/problems/zigzag-conversion/)|[Solution](../master/src/main/java/com/stevesun/solutions/_6.java) | O(n) | O(n) | Easy |
426-
|5|[Longest Palindromic Substring](https://leetcode.com/problems/longest-palindromic-substring/)|[Solution](../master/src/main/java/com/stevesun/solutions/LongestPalindromicSubstring.java) | O(n^2) | O(1) | Medium|
428+
|5|[Longest Palindromic Substring](https://leetcode.com/problems/longest-palindromic-substring/)|[Solution](../master/src/main/java/com/stevesun/solutions/_5.java) | O(n^2) | O(1) | Medium|
427429
|4|[Median of Two Sorted Arrays](https://leetcode.com/problems/median-of-two-sorted-arrays/)|[Solution](../master/src/main/java/com/stevesun/solutions/MedianofTwoSortedArrays.java) | ? | ? | Hard | Divide and Conquer
428430
|3|[Longest Substring Without Repeating Characters](https://leetcode.com/problems/longest-substring-without-repeating-characters/)|[Solution](../master/src/main/java/com/stevesun/solutions/LongestSubstringWithoutRepeatingCharacters.java) | O(n) | O(1) | Medium | HashMap, Sliding Window
429431
|2|[Add Two Numbers](https://leetcode.com/problems/add-two-numbers/)|[Solution](../master/src/main/java/com/stevesun/solutions/_2.java) | O(max(m,n)) | O(1) | Medium | LinkedList

src/main/java/com/stevesun/solutions/IntersectionofTwoLinkedLists.java

Lines changed: 0 additions & 37 deletions
This file was deleted.

src/main/java/com/stevesun/solutions/PowerOfTwo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public class PowerOfTwo {
88
public boolean isPowerOfTwo(int n) {
99
//after writing out the binary representation of some numbers: 1,2,4,8,16,32, you can easily figure out that
1010
//every number that is power of two has only one bit that is 1
11-
//then we can apply that cool trick that we learned from {@link easy.NumberOfIBits}: n&(n-1) which will clear the least significant bit in n to zero
11+
//then we can apply that cool trick that we learned from {@link easy._191}: n&(n-1) which will clear the least significant bit in n to zero
1212
return n> 0 && (n&(n-1)) == 0;
1313
}
1414

src/main/java/com/stevesun/solutions/SearchinRotatedSortedArray.java

Lines changed: 0 additions & 118 deletions
This file was deleted.

src/main/java/com/stevesun/solutions/BinaryTreeLevelOrderTraversal.java renamed to src/main/java/com/stevesun/solutions/_102.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
[15,7]
2929
]
3030
*/
31-
public class BinaryTreeLevelOrderTraversal {
31+
public class _102 {
3232
public List<List<Integer>> levelOrder(TreeNode root) {
3333
List<List<Integer>> result = new ArrayList<List<Integer>>();
3434
if(root == null) return result;

0 commit comments

Comments
 (0)