From 94dc3c8ba3b288333f7fedee25e335a66d97b5be Mon Sep 17 00:00:00 2001 From: DRFish <1993sj1993@gmail.com> Date: Mon, 13 Jun 2016 19:34:35 +0800 Subject: [PATCH 01/53] Number of Islands --- 200 Number of Islands.py | 50 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 200 Number of Islands.py diff --git a/200 Number of Islands.py b/200 Number of Islands.py new file mode 100644 index 0000000..fd7bc76 --- /dev/null +++ b/200 Number of Islands.py @@ -0,0 +1,50 @@ +''' +Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water. + +Example 1: + +11110 +11010 +11000 +00000 +Answer: 1 + +Example 2: + +11000 +11000 +00100 +00011 +Answer: 3 +''' + +class Solution(object): + def numIslands(self, grid): + """ + :type grid: List[List[str]] + :rtype: int + """ + if not grid: + return 0 + n = len(grid) + m = len(grid[0]) + + def dfs(i, j): + if 0 <= i < n and 0 <= j < m and grid[i][j] == '1': + grid[i][j] = '0' + dfs(i, j - 1) + dfs(i, j + 1) + dfs(i - 1, j) + dfs(i + 1, j) + return 1 + return 0 + + count = sum(dfs(i, j) for i in range(n) for j in range(m)) + return count + + +if __name__ == "__main__": + assert Solution().numIslands([['1', '1', '0', '0', '0'], + ['1', '1', '0', '0', '0'], + ['0', '0', '1', '0', '0'], + ['0', '0', '0', '1', '1']]) == 3 \ No newline at end of file From e083213ea35b6a82050d3fa24ce0a85d8a59ce5a Mon Sep 17 00:00:00 2001 From: DRFish <1993sj1993@gmail.com> Date: Mon, 5 Sep 2016 15:15:04 +0800 Subject: [PATCH 02/53] Contains Duplicate/ Contains Duplicate II --- 217 Contains Duplicate.py | 16 ++++++++++++++++ 219 Contains Duplicate II.py | 26 ++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 217 Contains Duplicate.py create mode 100644 219 Contains Duplicate II.py diff --git a/217 Contains Duplicate.py b/217 Contains Duplicate.py new file mode 100644 index 0000000..cd92596 --- /dev/null +++ b/217 Contains Duplicate.py @@ -0,0 +1,16 @@ +''' +Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every element is distinct. +''' + +class Solution(object): + def containsDuplicate(self, nums): + """ + :type nums: List[int] + :rtype: bool + """ + return len(nums) != len(set(nums)) + + +if __name__ == "__main__": + assert Solution().containsDuplicate([1, 2, 3, 4]) == False + assert Solution().containsDuplicate([1, 2, 3, 1]) == True \ No newline at end of file diff --git a/219 Contains Duplicate II.py b/219 Contains Duplicate II.py new file mode 100644 index 0000000..6925f87 --- /dev/null +++ b/219 Contains Duplicate II.py @@ -0,0 +1,26 @@ +''' +Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the difference between i and j is at most k. +''' + +class Solution(object): + def containsNearbyDuplicate(self, nums, k): + """ + :type nums: List[int] + :type k: int + :rtype: bool + """ + if not nums: + return False + m = {} + for i in range(len(nums)): + if nums[i] in m: + if i - m.get(nums[i]) <= k: + return True + m[nums[i]] = i + return False + + +if __name__ == "__main__": + assert Solution().containsNearbyDuplicate([1, 2, 3, 4], 1) == False + assert Solution().containsNearbyDuplicate([1, 1, 2, 3], 2) == True + assert Solution().containsNearbyDuplicate([1, 2, 3, 1], 2) == False \ No newline at end of file From e31112a533053bbf87f8514a771f1019d732a4e5 Mon Sep 17 00:00:00 2001 From: Shen Jie Date: Fri, 9 Dec 2016 13:46:51 +0800 Subject: [PATCH 03/53] Delete Node in a Linked List/ Product of Array Except Self --- 237 Delete Node in a Linked List.py | 35 +++++++++++++++++++++++++++++ 238 Product of Array Except Self.py | 30 +++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 237 Delete Node in a Linked List.py create mode 100644 238 Product of Array Except Self.py diff --git a/237 Delete Node in a Linked List.py b/237 Delete Node in a Linked List.py new file mode 100644 index 0000000..b48fe5c --- /dev/null +++ b/237 Delete Node in a Linked List.py @@ -0,0 +1,35 @@ +''' +Write a function to delete a node (except the tail) in a singly linked list, +given only access to that node. + +Supposed the linked list is 1 -> 2 -> 3 -> 4 and you are given the third node +with value 3, the linked list should become 1 -> 2 -> 4 after calling your +function. +''' + +# Definition for singly-linked list. +class ListNode(object): + def __init__(self, x): + self.val = x + self.next = None + +class Solution(object): + def deleteNode(self, node): + """ + :type node: ListNode + :rtype: void Do not return anything, modify node in-place instead. + """ + node.val = node.next.val + node.next = node.next.next + + +if __name__=="__main__": + n1 = ListNode(1) + n2 = ListNode(2) + n3 = ListNode(3) + n4 = ListNode(4) + n1.next = n2 + n2.next = n3 + n3.next = n4 + Solution().deleteNode(n3) + assert n2.next.val == 4 diff --git a/238 Product of Array Except Self.py b/238 Product of Array Except Self.py new file mode 100644 index 0000000..fba0d5b --- /dev/null +++ b/238 Product of Array Except Self.py @@ -0,0 +1,30 @@ +''' +Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i]. + +Solve it without division and in O(n). + +For example, given [1,2,3,4], return [24,12,8,6]. + +Follow up: +Could you solve it with constant space complexity? (Note: The output array does not count as extra space for the purpose of space complexity analysis.) +''' + +class Solution(object): + def productExceptSelf(self, nums): + """ + :type nums: List[int] + :rtype: List[int] + """ + n = len(nums) + result = [1] * n + for i in range(1, n): + result[i] = result[i - 1] * nums[i - 1] + temp = 1 + for i in range(n - 1, -1, -1): + result[i] *= temp + temp *= nums[i] + return result + + +if __name__ == "__main__": + assert Solution().productExceptSelf([1, 2, 3, 4]) == [24, 12, 8, 6] From 07e6ec535487cec49a05d7ba854b1940316ca007 Mon Sep 17 00:00:00 2001 From: Shen Jie Date: Sat, 10 Dec 2016 14:44:27 +0800 Subject: [PATCH 04/53] Palindrome Linked List/ Valid Anagram --- 234 Palindrome Linked List.py | 49 +++++++++++++++++++++++++++++++++++ 242 Valid Anagram.py | 39 ++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 234 Palindrome Linked List.py create mode 100644 242 Valid Anagram.py diff --git a/234 Palindrome Linked List.py b/234 Palindrome Linked List.py new file mode 100644 index 0000000..df60dbc --- /dev/null +++ b/234 Palindrome Linked List.py @@ -0,0 +1,49 @@ +''' +Given a singly linked list, determine if it is a palindrome. + +Follow up: +Could you do it in O(n) time and O(1) space? +''' + +# Definition for singly-linked list. +class ListNode(object): + def __init__(self, x): + self.val = x + self.next = None + + +class Solution(object): + def isPalindrome(self, head): + """ + :type head: ListNode + :rtype: bool + """ + # split the list into two parts, we can reverse the first part at meantime + fast = slow = head + reverse = None + while fast and fast.next: + fast = fast.next.next + reverse, reverse.next, slow = slow, reverse, slow.next + # if the total number is odd, skip the centre point + if fast: + slow = slow.next + # compare the reversed first part and normal second part + while reverse: + if reverse.val != slow.val: + return False + else: + reverse = reverse.next + slow = slow.next + return True + + +if __name__ == "__main__": + n1 = ListNode(1) + n2 = ListNode(2) + n3 = ListNode(1) + n1.next = n2 + n2.next = n3 + assert Solution().isPalindrome(n1) == True + assert Solution().isPalindrome(n2) == False + n1.next = n3 + assert Solution().isPalindrome(n1) == True diff --git a/242 Valid Anagram.py b/242 Valid Anagram.py new file mode 100644 index 0000000..64cf4e7 --- /dev/null +++ b/242 Valid Anagram.py @@ -0,0 +1,39 @@ +''' +Given two strings s and t, write a function to determine if t is an anagram of s. + +For example, +s = "anagram", t = "nagaram", return true. +s = "rat", t = "car", return false. + +Note: +You may assume the string contains only lowercase alphabets. + +Follow up: +What if the inputs contain unicode characters? How would you adapt your solution to such case? +''' + +class Solution(object): + def isAnagram(self, s, t): + """ + :type s: str + :type t: str + :rtype: bool + """ + m = {} + if len(s) != len(t): + return False + for c in s: + m[c] = m.get(c, 0) + 1 + for c in t: + if c not in m or m[c] == 0: + return False + else: + m[c] -= 1 + return True + + +if __name__ == "__main__": + s, t = "anagram", "nagaram" + assert Solution().isAnagram(s, t) == True + s, t = 'rat', 'car' + assert Solution().isAnagram(s, t) == False From 28ae35fdb4c47461a6615123d9d46ea606830f37 Mon Sep 17 00:00:00 2001 From: Shen Jie Date: Mon, 12 Dec 2016 15:40:16 +0800 Subject: [PATCH 05/53] Number of Digit One --- 233 Number of Digit One.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 233 Number of Digit One.py diff --git a/233 Number of Digit One.py b/233 Number of Digit One.py new file mode 100644 index 0000000..b0ec73c --- /dev/null +++ b/233 Number of Digit One.py @@ -0,0 +1,29 @@ +''' +Given an integer n, count the total number of digit 1 appearing in all non-negative integers less than or equal to n. + +For example: +Given n = 13, +Return 6, because digit 1 occurred in the following numbers: 1, 10, 11, 12, 13. +''' + +class Solution(object): + def countDigitOne(self, n): + """ + :type n: int + :rtype: int + """ + x, m, count = n, 1, 0 + while x > 0: + lastDigit = x % 10 + x //= 10 + count += x * m + if lastDigit == 1: + count += n % m + 1 + elif lastDigit > 1: + count += m + m *= 10 + return count + + +if __name__ == "__main__": + assert Solution().countDigitOne(13) == 6 From 2a25c01ea8fab4784024a2ee260c72c97abb2ab6 Mon Sep 17 00:00:00 2001 From: Shen Jie Date: Sat, 15 Apr 2017 09:27:22 +0800 Subject: [PATCH 06/53] change path for py files --- 001 Two Sum.py => python/001 Two Sum.py | 0 002 Add Two Numbers.py => python/002 Add Two Numbers.py | 0 .../003 Longest Substring Without Repeating Characters.py | 0 .../004 Median of Two Sorted Arrays.py | 0 .../005 Longest Palindromic Substring.py | 0 006 ZigZag Conversion.py => python/006 ZigZag Conversion.py | 0 007 Reverse Integer.py => python/007 Reverse Integer.py | 0 008 String to Integer.py => python/008 String to Integer.py | 0 009 Palindrome Number.py => python/009 Palindrome Number.py | 0 .../010 Regular Expression Matching.py | 0 .../011 Container With Most Water.py | 0 012 Integer to Roman.py => python/012 Integer to Roman.py | 0 013 Roman to Integer.py => python/013 Roman to Integer.py | 0 .../014 Longest Common Prefix.py | 0 015 3Sum.py => python/015 3Sum.py | 0 016 3Sum Closest.py => python/016 3Sum Closest.py | 0 .../017 Letter Combinations of a Phone Number.py | 0 018 4Sum.py => python/018 4Sum.py | 0 .../019 Remove Nth Node From End of List.py | 0 020 Valid Parentheses.py => python/020 Valid Parentheses.py | 0 .../021 Merge Two Sorted Lists.py | 0 022 Generate Parentheses.py => python/022 Generate Parentheses.py | 0 023 Merge k Sorted Lists.py => python/023 Merge k Sorted Lists.py | 0 024 Swap Nodes in Pairs.py => python/024 Swap Nodes in Pairs.py | 0 .../025 Reverse Nodes in k-Group.py | 0 .../026 Remove Duplicates from Sorted Array.py | 0 027 Remove Element.py => python/027 Remove Element.py | 0 028 Implement strStr().py => python/028 Implement strStr().py | 0 029 Divide Two Integers.py => python/029 Divide Two Integers.py | 0 .../030 Substring with Concatenation of All Words.py | 0 031 Next Permutation.py => python/031 Next Permutation.py | 0 .../032 Longest Valid Parentheses.py | 0 .../033 Search in Rotated Sorted Array.py | 0 034 Search for a Range.py => python/034 Search for a Range.py | 0 .../035 Search Insert Position.py | 0 036 Valid Sudoku.py => python/036 Valid Sudoku.py | 0 037 Sudoku Solver.py => python/037 Sudoku Solver.py | 0 038 Count and Say.py => python/038 Count and Say.py | 0 039 Combination Sum.py => python/039 Combination Sum.py | 0 040 Combination Sum II.py => python/040 Combination Sum II.py | 0 .../041 First Missing Positive.py | 0 042 Trapping Rain Water.py => python/042 Trapping Rain Water.py | 0 043 Multiply Strings.py => python/043 Multiply Strings.py | 0 044 Wildcard Matching.py => python/044 Wildcard Matching.py | 0 045 Jump Game II.py => python/045 Jump Game II.py | 0 046 Permutations.py => python/046 Permutations.py | 0 047 Permutations II.py => python/047 Permutations II.py | 0 048 Rotate Image.py => python/048 Rotate Image.py | 0 049 Group Anagrams.py => python/049 Group Anagrams.py | 0 050 Pow(x, n).py => python/050 Pow(x, n).py | 0 051 N-Queens.py => python/051 N-Queens.py | 0 052 N-Queens II.py => python/052 N-Queens II.py | 0 053 Maximum Subarray.py => python/053 Maximum Subarray.py | 0 054 Spiral Matrix.py => python/054 Spiral Matrix.py | 0 055 Jump Game.py => python/055 Jump Game.py | 0 056 Merge Intervals.py => python/056 Merge Intervals.py | 0 057 Insert Interval.py => python/057 Insert Interval.py | 0 058 Length of Last Word.py => python/058 Length of Last Word.py | 0 059 Spiral Matrix II.py => python/059 Spiral Matrix II.py | 0 060 Permutation Sequence.py => python/060 Permutation Sequence.py | 0 061 Rotate List.py => python/061 Rotate List.py | 0 062 Unique Paths.py => python/062 Unique Paths.py | 0 063 Unique Paths II.py => python/063 Unique Paths II.py | 0 064 Minimum Path Sum.py => python/064 Minimum Path Sum.py | 0 065 Valid Number.py => python/065 Valid Number.py | 0 066 Plus One.py => python/066 Plus One.py | 0 067 Add Binary.py => python/067 Add Binary.py | 0 068 Text Justification.py => python/068 Text Justification.py | 0 069 Sqrt(x).py => python/069 Sqrt(x).py | 0 070 Climbing Stairs.py => python/070 Climbing Stairs.py | 0 071 Simplify Path.py => python/071 Simplify Path.py | 0 072 Edit Distance.py => python/072 Edit Distance.py | 0 073 Set Matrix Zeroes.py => python/073 Set Matrix Zeroes.py | 0 074 Search a 2D Matrix.py => python/074 Search a 2D Matrix.py | 0 075 Sort Colors.py => python/075 Sort Colors.py | 0 .../076 Minimum Window Substring.py | 0 077 Combinations.py => python/077 Combinations.py | 0 078 Subsets.py => python/078 Subsets.py | 0 079 Word Search.py => python/079 Word Search.py | 0 .../080 Remove Duplicates from Sorted Array II.py | 0 .../081 Search in Rotated Sorted Array II.py | 0 .../082 Remove Duplicates from Sorted List II.py | 0 .../083 Remove Duplicates from Sorted List.py | 0 .../084 Largest Rectangle in Histogram.py | 0 085 Maximal Rectangle.py => python/085 Maximal Rectangle.py | 0 086 Partition List.py => python/086 Partition List.py | 0 087 Scramble String.py => python/087 Scramble String.py | 0 088 Merge Sorted Array.py => python/088 Merge Sorted Array.py | 0 089 Gray Code.py => python/089 Gray Code.py | 0 090 Subsets II.py => python/090 Subsets II.py | 0 091 Decode Ways.py => python/091 Decode Ways.py | 0 .../092 Reverse Linked List II.py | 0 093 Restore IP Addresses.py => python/093 Restore IP Addresses.py | 0 .../094 Binary Tree Inorder Traversal.py | 0 .../095 Unique Binary Search Trees II.py | 0 .../096 Unique Binary Search Trees.py | 0 097 Interleaving String.py => python/097 Interleaving String.py | 0 .../098 Validate Binary Search Tree.py | 0 .../099 Recover Binary Search Tree.py | 0 100 Same Tree.py => python/100 Same Tree.py | 0 101 Symmetric Tree.py => python/101 Symmetric Tree.py | 0 .../102 Binary Tree Level Order Traversal.py | 0 .../103 Binary Tree Zigzag Level Order Traversal.py | 0 .../104 Maximum Depth of Binary Tree.py | 0 ...5 Construct Binary Tree from Preorder and Inorder Traversal.py | 0 ... Construct Binary Tree from Inorder and Postorder Traversal.py | 0 .../107 Binary Tree Level Order Traversal II.py | 0 .../108 Convert Sorted Array to Binary Search Tree.py | 0 .../109 Convert Sorted List to Binary Search Tree.py | 0 110 Balanced Binary Tree.py => python/110 Balanced Binary Tree.py | 0 .../111 Minimum Depth of Binary Tree.py | 0 112 Path Sum.py => python/112 Path Sum.py | 0 113 Path Sum II.py => python/113 Path Sum II.py | 0 .../114 Flatten Binary Tree to Linked List.py | 0 .../115 Distinct Subsequences.py | 0 .../116 Populating Next Right Pointers in Each Node.py | 0 .../117 Populating Next Right Pointers in Each Node II.py | 0 118 Pascal's Triangle.py => python/118 Pascal's Triangle.py | 0 119 Pascal's Triangle II.py => python/119 Pascal's Triangle II.py | 0 120 Triangle.py => python/120 Triangle.py | 0 .../121 Best Time to Buy and Sell Stock.py | 0 .../122 Best Time to Buy and Sell Stock II.py | 0 .../123 Best Time to Buy and Sell Stock III.py | 0 .../124 Binary Tree Maximum Path Sum.py | 0 125 Valid Palindrome.py => python/125 Valid Palindrome.py | 0 126 Word Ladder II.py => python/126 Word Ladder II.py | 0 127 Word Ladder.py => python/127 Word Ladder.py | 0 .../128 Longest Consecutive Sequence.py | 0 .../129 Sum Root to Leaf Numbers.py | 0 130 Surrounded Regions.py => python/130 Surrounded Regions.py | 0 .../131 Palindrome Partitioning.py | 0 .../132 Palindrome Partitioning II.py | 0 133 Clone Graph.py => python/133 Clone Graph.py | 0 134 Gas Station.py => python/134 Gas Station.py | 0 135 Candy.py => python/135 Candy.py | 0 136 Single Number.py => python/136 Single Number.py | 0 137 Single Number II.py => python/137 Single Number II.py | 0 .../138 Copy List with Random Pointer.py | 0 139 Word Break.py => python/139 Word Break.py | 0 140 Word Break II.py => python/140 Word Break II.py | 0 141 Linked List Cycle.py => python/141 Linked List Cycle.py | 0 142 Linked List Cycle II.py => python/142 Linked List Cycle II.py | 0 143 Reorder List.py => python/143 Reorder List.py | 0 .../144 Binary Tree Preorder Traversal.py | 0 .../145 Binary Tree Postorder Traversal.py | 0 146 LRU Cache.py => python/146 LRU Cache.py | 0 147 Insertion Sort List.py => python/147 Insertion Sort List.py | 0 149 Max Points on a Line.py => python/149 Max Points on a Line.py | 0 .../150 Evaluate Reverse Polish Notation.py | 0 .../151 Reverse Words in a String.py | 0 .../152 Maximum Product Subarray.py | 0 .../153 Find Minimum in Rotated Sorted Array.py | 0 155 Min Stack.py => python/155 Min Stack.py | 0 .../160 Intersection of Two Linked Lists.py | 0 162 Find Peak Element.py => python/162 Find Peak Element.py | 0 164 Maximum Gap.py => python/164 Maximum Gap.py | 0 .../165 Compare Version Numbers.py | 0 .../166 Fraction to Recurring Decimal.py | 0 .../168 Excel Sheet Column Title.py | 0 169 Majority Element.py => python/169 Majority Element.py | 0 .../171 Excel Sheet Column Number.py | 0 .../172 Factorial Trailing Zeroes.py | 0 .../173 Binary Search Tree Iterator.py | 0 174 Dungeon Game.py => python/174 Dungeon Game.py | 0 179 Largest Number.py => python/179 Largest Number.py | 0 189 Rotate Array.py => python/189 Rotate Array.py | 0 190 Reverse Bits.py => python/190 Reverse Bits.py | 0 191 Number of 1 Bits.py => python/191 Number of 1 Bits.py | 0 198 House Robber.py => python/198 House Robber.py | 0 .../199 Binary Tree Right Side View.py | 0 200 Number of Islands.py => python/200 Number of Islands.py | 0 .../201 Bitwise AND of Numbers Range.py | 0 202 Happy Number.py => python/202 Happy Number.py | 0 .../203 Remove Linked List Elements.py | 0 204 Count Primes.py => python/204 Count Primes.py | 0 205 Isomorphic Strings.py => python/205 Isomorphic Strings.py | 0 206 Reverse Linked List.py => python/206 Reverse Linked List.py | 0 217 Contains Duplicate.py => python/217 Contains Duplicate.py | 0 .../219 Contains Duplicate II.py | 0 233 Number of Digit One.py => python/233 Number of Digit One.py | 0 .../234 Palindrome Linked List.py | 0 .../237 Delete Node in a Linked List.py | 0 .../238 Product of Array Except Self.py | 0 242 Valid Anagram.py => python/242 Valid Anagram.py | 0 184 files changed, 0 insertions(+), 0 deletions(-) rename 001 Two Sum.py => python/001 Two Sum.py (100%) rename 002 Add Two Numbers.py => python/002 Add Two Numbers.py (100%) rename 003 Longest Substring Without Repeating Characters.py => python/003 Longest Substring Without Repeating Characters.py (100%) rename 004 Median of Two Sorted Arrays.py => python/004 Median of Two Sorted Arrays.py (100%) rename 005 Longest Palindromic Substring.py => python/005 Longest Palindromic Substring.py (100%) rename 006 ZigZag Conversion.py => python/006 ZigZag Conversion.py (100%) rename 007 Reverse Integer.py => python/007 Reverse Integer.py (100%) rename 008 String to Integer.py => python/008 String to Integer.py (100%) rename 009 Palindrome Number.py => python/009 Palindrome Number.py (100%) rename 010 Regular Expression Matching.py => python/010 Regular Expression Matching.py (100%) rename 011 Container With Most Water.py => python/011 Container With Most Water.py (100%) rename 012 Integer to Roman.py => python/012 Integer to Roman.py (100%) rename 013 Roman to Integer.py => python/013 Roman to Integer.py (100%) rename 014 Longest Common Prefix.py => python/014 Longest Common Prefix.py (100%) rename 015 3Sum.py => python/015 3Sum.py (100%) rename 016 3Sum Closest.py => python/016 3Sum Closest.py (100%) rename 017 Letter Combinations of a Phone Number.py => python/017 Letter Combinations of a Phone Number.py (100%) rename 018 4Sum.py => python/018 4Sum.py (100%) rename 019 Remove Nth Node From End of List.py => python/019 Remove Nth Node From End of List.py (100%) rename 020 Valid Parentheses.py => python/020 Valid Parentheses.py (100%) rename 021 Merge Two Sorted Lists.py => python/021 Merge Two Sorted Lists.py (100%) rename 022 Generate Parentheses.py => python/022 Generate Parentheses.py (100%) rename 023 Merge k Sorted Lists.py => python/023 Merge k Sorted Lists.py (100%) rename 024 Swap Nodes in Pairs.py => python/024 Swap Nodes in Pairs.py (100%) rename 025 Reverse Nodes in k-Group.py => python/025 Reverse Nodes in k-Group.py (100%) rename 026 Remove Duplicates from Sorted Array.py => python/026 Remove Duplicates from Sorted Array.py (100%) rename 027 Remove Element.py => python/027 Remove Element.py (100%) rename 028 Implement strStr().py => python/028 Implement strStr().py (100%) rename 029 Divide Two Integers.py => python/029 Divide Two Integers.py (100%) rename 030 Substring with Concatenation of All Words.py => python/030 Substring with Concatenation of All Words.py (100%) rename 031 Next Permutation.py => python/031 Next Permutation.py (100%) rename 032 Longest Valid Parentheses.py => python/032 Longest Valid Parentheses.py (100%) rename 033 Search in Rotated Sorted Array.py => python/033 Search in Rotated Sorted Array.py (100%) rename 034 Search for a Range.py => python/034 Search for a Range.py (100%) rename 035 Search Insert Position.py => python/035 Search Insert Position.py (100%) rename 036 Valid Sudoku.py => python/036 Valid Sudoku.py (100%) rename 037 Sudoku Solver.py => python/037 Sudoku Solver.py (100%) rename 038 Count and Say.py => python/038 Count and Say.py (100%) rename 039 Combination Sum.py => python/039 Combination Sum.py (100%) rename 040 Combination Sum II.py => python/040 Combination Sum II.py (100%) rename 041 First Missing Positive.py => python/041 First Missing Positive.py (100%) rename 042 Trapping Rain Water.py => python/042 Trapping Rain Water.py (100%) rename 043 Multiply Strings.py => python/043 Multiply Strings.py (100%) rename 044 Wildcard Matching.py => python/044 Wildcard Matching.py (100%) rename 045 Jump Game II.py => python/045 Jump Game II.py (100%) rename 046 Permutations.py => python/046 Permutations.py (100%) rename 047 Permutations II.py => python/047 Permutations II.py (100%) rename 048 Rotate Image.py => python/048 Rotate Image.py (100%) rename 049 Group Anagrams.py => python/049 Group Anagrams.py (100%) rename 050 Pow(x, n).py => python/050 Pow(x, n).py (100%) rename 051 N-Queens.py => python/051 N-Queens.py (100%) rename 052 N-Queens II.py => python/052 N-Queens II.py (100%) rename 053 Maximum Subarray.py => python/053 Maximum Subarray.py (100%) rename 054 Spiral Matrix.py => python/054 Spiral Matrix.py (100%) rename 055 Jump Game.py => python/055 Jump Game.py (100%) rename 056 Merge Intervals.py => python/056 Merge Intervals.py (100%) rename 057 Insert Interval.py => python/057 Insert Interval.py (100%) rename 058 Length of Last Word.py => python/058 Length of Last Word.py (100%) rename 059 Spiral Matrix II.py => python/059 Spiral Matrix II.py (100%) rename 060 Permutation Sequence.py => python/060 Permutation Sequence.py (100%) rename 061 Rotate List.py => python/061 Rotate List.py (100%) rename 062 Unique Paths.py => python/062 Unique Paths.py (100%) rename 063 Unique Paths II.py => python/063 Unique Paths II.py (100%) rename 064 Minimum Path Sum.py => python/064 Minimum Path Sum.py (100%) rename 065 Valid Number.py => python/065 Valid Number.py (100%) rename 066 Plus One.py => python/066 Plus One.py (100%) rename 067 Add Binary.py => python/067 Add Binary.py (100%) rename 068 Text Justification.py => python/068 Text Justification.py (100%) rename 069 Sqrt(x).py => python/069 Sqrt(x).py (100%) rename 070 Climbing Stairs.py => python/070 Climbing Stairs.py (100%) rename 071 Simplify Path.py => python/071 Simplify Path.py (100%) rename 072 Edit Distance.py => python/072 Edit Distance.py (100%) rename 073 Set Matrix Zeroes.py => python/073 Set Matrix Zeroes.py (100%) rename 074 Search a 2D Matrix.py => python/074 Search a 2D Matrix.py (100%) rename 075 Sort Colors.py => python/075 Sort Colors.py (100%) rename 076 Minimum Window Substring.py => python/076 Minimum Window Substring.py (100%) rename 077 Combinations.py => python/077 Combinations.py (100%) rename 078 Subsets.py => python/078 Subsets.py (100%) rename 079 Word Search.py => python/079 Word Search.py (100%) rename 080 Remove Duplicates from Sorted Array II.py => python/080 Remove Duplicates from Sorted Array II.py (100%) rename 081 Search in Rotated Sorted Array II.py => python/081 Search in Rotated Sorted Array II.py (100%) rename 082 Remove Duplicates from Sorted List II.py => python/082 Remove Duplicates from Sorted List II.py (100%) rename 083 Remove Duplicates from Sorted List.py => python/083 Remove Duplicates from Sorted List.py (100%) rename 084 Largest Rectangle in Histogram.py => python/084 Largest Rectangle in Histogram.py (100%) rename 085 Maximal Rectangle.py => python/085 Maximal Rectangle.py (100%) rename 086 Partition List.py => python/086 Partition List.py (100%) rename 087 Scramble String.py => python/087 Scramble String.py (100%) rename 088 Merge Sorted Array.py => python/088 Merge Sorted Array.py (100%) rename 089 Gray Code.py => python/089 Gray Code.py (100%) rename 090 Subsets II.py => python/090 Subsets II.py (100%) rename 091 Decode Ways.py => python/091 Decode Ways.py (100%) rename 092 Reverse Linked List II.py => python/092 Reverse Linked List II.py (100%) rename 093 Restore IP Addresses.py => python/093 Restore IP Addresses.py (100%) rename 094 Binary Tree Inorder Traversal.py => python/094 Binary Tree Inorder Traversal.py (100%) rename 095 Unique Binary Search Trees II.py => python/095 Unique Binary Search Trees II.py (100%) rename 096 Unique Binary Search Trees.py => python/096 Unique Binary Search Trees.py (100%) rename 097 Interleaving String.py => python/097 Interleaving String.py (100%) rename 098 Validate Binary Search Tree.py => python/098 Validate Binary Search Tree.py (100%) rename 099 Recover Binary Search Tree.py => python/099 Recover Binary Search Tree.py (100%) rename 100 Same Tree.py => python/100 Same Tree.py (100%) rename 101 Symmetric Tree.py => python/101 Symmetric Tree.py (100%) rename 102 Binary Tree Level Order Traversal.py => python/102 Binary Tree Level Order Traversal.py (100%) rename 103 Binary Tree Zigzag Level Order Traversal.py => python/103 Binary Tree Zigzag Level Order Traversal.py (100%) rename 104 Maximum Depth of Binary Tree.py => python/104 Maximum Depth of Binary Tree.py (100%) rename 105 Construct Binary Tree from Preorder and Inorder Traversal.py => python/105 Construct Binary Tree from Preorder and Inorder Traversal.py (100%) rename 106 Construct Binary Tree from Inorder and Postorder Traversal.py => python/106 Construct Binary Tree from Inorder and Postorder Traversal.py (100%) rename 107 Binary Tree Level Order Traversal II.py => python/107 Binary Tree Level Order Traversal II.py (100%) rename 108 Convert Sorted Array to Binary Search Tree.py => python/108 Convert Sorted Array to Binary Search Tree.py (100%) rename 109 Convert Sorted List to Binary Search Tree.py => python/109 Convert Sorted List to Binary Search Tree.py (100%) rename 110 Balanced Binary Tree.py => python/110 Balanced Binary Tree.py (100%) rename 111 Minimum Depth of Binary Tree.py => python/111 Minimum Depth of Binary Tree.py (100%) rename 112 Path Sum.py => python/112 Path Sum.py (100%) rename 113 Path Sum II.py => python/113 Path Sum II.py (100%) rename 114 Flatten Binary Tree to Linked List.py => python/114 Flatten Binary Tree to Linked List.py (100%) rename 115 Distinct Subsequences.py => python/115 Distinct Subsequences.py (100%) rename 116 Populating Next Right Pointers in Each Node.py => python/116 Populating Next Right Pointers in Each Node.py (100%) rename 117 Populating Next Right Pointers in Each Node II.py => python/117 Populating Next Right Pointers in Each Node II.py (100%) rename 118 Pascal's Triangle.py => python/118 Pascal's Triangle.py (100%) rename 119 Pascal's Triangle II.py => python/119 Pascal's Triangle II.py (100%) rename 120 Triangle.py => python/120 Triangle.py (100%) rename 121 Best Time to Buy and Sell Stock.py => python/121 Best Time to Buy and Sell Stock.py (100%) rename 122 Best Time to Buy and Sell Stock II.py => python/122 Best Time to Buy and Sell Stock II.py (100%) rename 123 Best Time to Buy and Sell Stock III.py => python/123 Best Time to Buy and Sell Stock III.py (100%) rename 124 Binary Tree Maximum Path Sum.py => python/124 Binary Tree Maximum Path Sum.py (100%) rename 125 Valid Palindrome.py => python/125 Valid Palindrome.py (100%) rename 126 Word Ladder II.py => python/126 Word Ladder II.py (100%) rename 127 Word Ladder.py => python/127 Word Ladder.py (100%) rename 128 Longest Consecutive Sequence.py => python/128 Longest Consecutive Sequence.py (100%) rename 129 Sum Root to Leaf Numbers.py => python/129 Sum Root to Leaf Numbers.py (100%) rename 130 Surrounded Regions.py => python/130 Surrounded Regions.py (100%) rename 131 Palindrome Partitioning.py => python/131 Palindrome Partitioning.py (100%) rename 132 Palindrome Partitioning II.py => python/132 Palindrome Partitioning II.py (100%) rename 133 Clone Graph.py => python/133 Clone Graph.py (100%) rename 134 Gas Station.py => python/134 Gas Station.py (100%) rename 135 Candy.py => python/135 Candy.py (100%) rename 136 Single Number.py => python/136 Single Number.py (100%) rename 137 Single Number II.py => python/137 Single Number II.py (100%) rename 138 Copy List with Random Pointer.py => python/138 Copy List with Random Pointer.py (100%) rename 139 Word Break.py => python/139 Word Break.py (100%) rename 140 Word Break II.py => python/140 Word Break II.py (100%) rename 141 Linked List Cycle.py => python/141 Linked List Cycle.py (100%) rename 142 Linked List Cycle II.py => python/142 Linked List Cycle II.py (100%) rename 143 Reorder List.py => python/143 Reorder List.py (100%) rename 144 Binary Tree Preorder Traversal.py => python/144 Binary Tree Preorder Traversal.py (100%) rename 145 Binary Tree Postorder Traversal.py => python/145 Binary Tree Postorder Traversal.py (100%) rename 146 LRU Cache.py => python/146 LRU Cache.py (100%) rename 147 Insertion Sort List.py => python/147 Insertion Sort List.py (100%) rename 149 Max Points on a Line.py => python/149 Max Points on a Line.py (100%) rename 150 Evaluate Reverse Polish Notation.py => python/150 Evaluate Reverse Polish Notation.py (100%) rename 151 Reverse Words in a String.py => python/151 Reverse Words in a String.py (100%) rename 152 Maximum Product Subarray.py => python/152 Maximum Product Subarray.py (100%) rename 153 Find Minimum in Rotated Sorted Array.py => python/153 Find Minimum in Rotated Sorted Array.py (100%) rename 155 Min Stack.py => python/155 Min Stack.py (100%) rename 160 Intersection of Two Linked Lists.py => python/160 Intersection of Two Linked Lists.py (100%) rename 162 Find Peak Element.py => python/162 Find Peak Element.py (100%) rename 164 Maximum Gap.py => python/164 Maximum Gap.py (100%) rename 165 Compare Version Numbers.py => python/165 Compare Version Numbers.py (100%) rename 166 Fraction to Recurring Decimal.py => python/166 Fraction to Recurring Decimal.py (100%) rename 168 Excel Sheet Column Title.py => python/168 Excel Sheet Column Title.py (100%) rename 169 Majority Element.py => python/169 Majority Element.py (100%) rename 171 Excel Sheet Column Number.py => python/171 Excel Sheet Column Number.py (100%) rename 172 Factorial Trailing Zeroes.py => python/172 Factorial Trailing Zeroes.py (100%) rename 173 Binary Search Tree Iterator.py => python/173 Binary Search Tree Iterator.py (100%) rename 174 Dungeon Game.py => python/174 Dungeon Game.py (100%) rename 179 Largest Number.py => python/179 Largest Number.py (100%) rename 189 Rotate Array.py => python/189 Rotate Array.py (100%) rename 190 Reverse Bits.py => python/190 Reverse Bits.py (100%) rename 191 Number of 1 Bits.py => python/191 Number of 1 Bits.py (100%) rename 198 House Robber.py => python/198 House Robber.py (100%) rename 199 Binary Tree Right Side View.py => python/199 Binary Tree Right Side View.py (100%) rename 200 Number of Islands.py => python/200 Number of Islands.py (100%) rename 201 Bitwise AND of Numbers Range.py => python/201 Bitwise AND of Numbers Range.py (100%) rename 202 Happy Number.py => python/202 Happy Number.py (100%) rename 203 Remove Linked List Elements.py => python/203 Remove Linked List Elements.py (100%) rename 204 Count Primes.py => python/204 Count Primes.py (100%) rename 205 Isomorphic Strings.py => python/205 Isomorphic Strings.py (100%) rename 206 Reverse Linked List.py => python/206 Reverse Linked List.py (100%) rename 217 Contains Duplicate.py => python/217 Contains Duplicate.py (100%) rename 219 Contains Duplicate II.py => python/219 Contains Duplicate II.py (100%) rename 233 Number of Digit One.py => python/233 Number of Digit One.py (100%) rename 234 Palindrome Linked List.py => python/234 Palindrome Linked List.py (100%) rename 237 Delete Node in a Linked List.py => python/237 Delete Node in a Linked List.py (100%) rename 238 Product of Array Except Self.py => python/238 Product of Array Except Self.py (100%) rename 242 Valid Anagram.py => python/242 Valid Anagram.py (100%) diff --git a/001 Two Sum.py b/python/001 Two Sum.py similarity index 100% rename from 001 Two Sum.py rename to python/001 Two Sum.py diff --git a/002 Add Two Numbers.py b/python/002 Add Two Numbers.py similarity index 100% rename from 002 Add Two Numbers.py rename to python/002 Add Two Numbers.py diff --git a/003 Longest Substring Without Repeating Characters.py b/python/003 Longest Substring Without Repeating Characters.py similarity index 100% rename from 003 Longest Substring Without Repeating Characters.py rename to python/003 Longest Substring Without Repeating Characters.py diff --git a/004 Median of Two Sorted Arrays.py b/python/004 Median of Two Sorted Arrays.py similarity index 100% rename from 004 Median of Two Sorted Arrays.py rename to python/004 Median of Two Sorted Arrays.py diff --git a/005 Longest Palindromic Substring.py b/python/005 Longest Palindromic Substring.py similarity index 100% rename from 005 Longest Palindromic Substring.py rename to python/005 Longest Palindromic Substring.py diff --git a/006 ZigZag Conversion.py b/python/006 ZigZag Conversion.py similarity index 100% rename from 006 ZigZag Conversion.py rename to python/006 ZigZag Conversion.py diff --git a/007 Reverse Integer.py b/python/007 Reverse Integer.py similarity index 100% rename from 007 Reverse Integer.py rename to python/007 Reverse Integer.py diff --git a/008 String to Integer.py b/python/008 String to Integer.py similarity index 100% rename from 008 String to Integer.py rename to python/008 String to Integer.py diff --git a/009 Palindrome Number.py b/python/009 Palindrome Number.py similarity index 100% rename from 009 Palindrome Number.py rename to python/009 Palindrome Number.py diff --git a/010 Regular Expression Matching.py b/python/010 Regular Expression Matching.py similarity index 100% rename from 010 Regular Expression Matching.py rename to python/010 Regular Expression Matching.py diff --git a/011 Container With Most Water.py b/python/011 Container With Most Water.py similarity index 100% rename from 011 Container With Most Water.py rename to python/011 Container With Most Water.py diff --git a/012 Integer to Roman.py b/python/012 Integer to Roman.py similarity index 100% rename from 012 Integer to Roman.py rename to python/012 Integer to Roman.py diff --git a/013 Roman to Integer.py b/python/013 Roman to Integer.py similarity index 100% rename from 013 Roman to Integer.py rename to python/013 Roman to Integer.py diff --git a/014 Longest Common Prefix.py b/python/014 Longest Common Prefix.py similarity index 100% rename from 014 Longest Common Prefix.py rename to python/014 Longest Common Prefix.py diff --git a/015 3Sum.py b/python/015 3Sum.py similarity index 100% rename from 015 3Sum.py rename to python/015 3Sum.py diff --git a/016 3Sum Closest.py b/python/016 3Sum Closest.py similarity index 100% rename from 016 3Sum Closest.py rename to python/016 3Sum Closest.py diff --git a/017 Letter Combinations of a Phone Number.py b/python/017 Letter Combinations of a Phone Number.py similarity index 100% rename from 017 Letter Combinations of a Phone Number.py rename to python/017 Letter Combinations of a Phone Number.py diff --git a/018 4Sum.py b/python/018 4Sum.py similarity index 100% rename from 018 4Sum.py rename to python/018 4Sum.py diff --git a/019 Remove Nth Node From End of List.py b/python/019 Remove Nth Node From End of List.py similarity index 100% rename from 019 Remove Nth Node From End of List.py rename to python/019 Remove Nth Node From End of List.py diff --git a/020 Valid Parentheses.py b/python/020 Valid Parentheses.py similarity index 100% rename from 020 Valid Parentheses.py rename to python/020 Valid Parentheses.py diff --git a/021 Merge Two Sorted Lists.py b/python/021 Merge Two Sorted Lists.py similarity index 100% rename from 021 Merge Two Sorted Lists.py rename to python/021 Merge Two Sorted Lists.py diff --git a/022 Generate Parentheses.py b/python/022 Generate Parentheses.py similarity index 100% rename from 022 Generate Parentheses.py rename to python/022 Generate Parentheses.py diff --git a/023 Merge k Sorted Lists.py b/python/023 Merge k Sorted Lists.py similarity index 100% rename from 023 Merge k Sorted Lists.py rename to python/023 Merge k Sorted Lists.py diff --git a/024 Swap Nodes in Pairs.py b/python/024 Swap Nodes in Pairs.py similarity index 100% rename from 024 Swap Nodes in Pairs.py rename to python/024 Swap Nodes in Pairs.py diff --git a/025 Reverse Nodes in k-Group.py b/python/025 Reverse Nodes in k-Group.py similarity index 100% rename from 025 Reverse Nodes in k-Group.py rename to python/025 Reverse Nodes in k-Group.py diff --git a/026 Remove Duplicates from Sorted Array.py b/python/026 Remove Duplicates from Sorted Array.py similarity index 100% rename from 026 Remove Duplicates from Sorted Array.py rename to python/026 Remove Duplicates from Sorted Array.py diff --git a/027 Remove Element.py b/python/027 Remove Element.py similarity index 100% rename from 027 Remove Element.py rename to python/027 Remove Element.py diff --git a/028 Implement strStr().py b/python/028 Implement strStr().py similarity index 100% rename from 028 Implement strStr().py rename to python/028 Implement strStr().py diff --git a/029 Divide Two Integers.py b/python/029 Divide Two Integers.py similarity index 100% rename from 029 Divide Two Integers.py rename to python/029 Divide Two Integers.py diff --git a/030 Substring with Concatenation of All Words.py b/python/030 Substring with Concatenation of All Words.py similarity index 100% rename from 030 Substring with Concatenation of All Words.py rename to python/030 Substring with Concatenation of All Words.py diff --git a/031 Next Permutation.py b/python/031 Next Permutation.py similarity index 100% rename from 031 Next Permutation.py rename to python/031 Next Permutation.py diff --git a/032 Longest Valid Parentheses.py b/python/032 Longest Valid Parentheses.py similarity index 100% rename from 032 Longest Valid Parentheses.py rename to python/032 Longest Valid Parentheses.py diff --git a/033 Search in Rotated Sorted Array.py b/python/033 Search in Rotated Sorted Array.py similarity index 100% rename from 033 Search in Rotated Sorted Array.py rename to python/033 Search in Rotated Sorted Array.py diff --git a/034 Search for a Range.py b/python/034 Search for a Range.py similarity index 100% rename from 034 Search for a Range.py rename to python/034 Search for a Range.py diff --git a/035 Search Insert Position.py b/python/035 Search Insert Position.py similarity index 100% rename from 035 Search Insert Position.py rename to python/035 Search Insert Position.py diff --git a/036 Valid Sudoku.py b/python/036 Valid Sudoku.py similarity index 100% rename from 036 Valid Sudoku.py rename to python/036 Valid Sudoku.py diff --git a/037 Sudoku Solver.py b/python/037 Sudoku Solver.py similarity index 100% rename from 037 Sudoku Solver.py rename to python/037 Sudoku Solver.py diff --git a/038 Count and Say.py b/python/038 Count and Say.py similarity index 100% rename from 038 Count and Say.py rename to python/038 Count and Say.py diff --git a/039 Combination Sum.py b/python/039 Combination Sum.py similarity index 100% rename from 039 Combination Sum.py rename to python/039 Combination Sum.py diff --git a/040 Combination Sum II.py b/python/040 Combination Sum II.py similarity index 100% rename from 040 Combination Sum II.py rename to python/040 Combination Sum II.py diff --git a/041 First Missing Positive.py b/python/041 First Missing Positive.py similarity index 100% rename from 041 First Missing Positive.py rename to python/041 First Missing Positive.py diff --git a/042 Trapping Rain Water.py b/python/042 Trapping Rain Water.py similarity index 100% rename from 042 Trapping Rain Water.py rename to python/042 Trapping Rain Water.py diff --git a/043 Multiply Strings.py b/python/043 Multiply Strings.py similarity index 100% rename from 043 Multiply Strings.py rename to python/043 Multiply Strings.py diff --git a/044 Wildcard Matching.py b/python/044 Wildcard Matching.py similarity index 100% rename from 044 Wildcard Matching.py rename to python/044 Wildcard Matching.py diff --git a/045 Jump Game II.py b/python/045 Jump Game II.py similarity index 100% rename from 045 Jump Game II.py rename to python/045 Jump Game II.py diff --git a/046 Permutations.py b/python/046 Permutations.py similarity index 100% rename from 046 Permutations.py rename to python/046 Permutations.py diff --git a/047 Permutations II.py b/python/047 Permutations II.py similarity index 100% rename from 047 Permutations II.py rename to python/047 Permutations II.py diff --git a/048 Rotate Image.py b/python/048 Rotate Image.py similarity index 100% rename from 048 Rotate Image.py rename to python/048 Rotate Image.py diff --git a/049 Group Anagrams.py b/python/049 Group Anagrams.py similarity index 100% rename from 049 Group Anagrams.py rename to python/049 Group Anagrams.py diff --git a/050 Pow(x, n).py b/python/050 Pow(x, n).py similarity index 100% rename from 050 Pow(x, n).py rename to python/050 Pow(x, n).py diff --git a/051 N-Queens.py b/python/051 N-Queens.py similarity index 100% rename from 051 N-Queens.py rename to python/051 N-Queens.py diff --git a/052 N-Queens II.py b/python/052 N-Queens II.py similarity index 100% rename from 052 N-Queens II.py rename to python/052 N-Queens II.py diff --git a/053 Maximum Subarray.py b/python/053 Maximum Subarray.py similarity index 100% rename from 053 Maximum Subarray.py rename to python/053 Maximum Subarray.py diff --git a/054 Spiral Matrix.py b/python/054 Spiral Matrix.py similarity index 100% rename from 054 Spiral Matrix.py rename to python/054 Spiral Matrix.py diff --git a/055 Jump Game.py b/python/055 Jump Game.py similarity index 100% rename from 055 Jump Game.py rename to python/055 Jump Game.py diff --git a/056 Merge Intervals.py b/python/056 Merge Intervals.py similarity index 100% rename from 056 Merge Intervals.py rename to python/056 Merge Intervals.py diff --git a/057 Insert Interval.py b/python/057 Insert Interval.py similarity index 100% rename from 057 Insert Interval.py rename to python/057 Insert Interval.py diff --git a/058 Length of Last Word.py b/python/058 Length of Last Word.py similarity index 100% rename from 058 Length of Last Word.py rename to python/058 Length of Last Word.py diff --git a/059 Spiral Matrix II.py b/python/059 Spiral Matrix II.py similarity index 100% rename from 059 Spiral Matrix II.py rename to python/059 Spiral Matrix II.py diff --git a/060 Permutation Sequence.py b/python/060 Permutation Sequence.py similarity index 100% rename from 060 Permutation Sequence.py rename to python/060 Permutation Sequence.py diff --git a/061 Rotate List.py b/python/061 Rotate List.py similarity index 100% rename from 061 Rotate List.py rename to python/061 Rotate List.py diff --git a/062 Unique Paths.py b/python/062 Unique Paths.py similarity index 100% rename from 062 Unique Paths.py rename to python/062 Unique Paths.py diff --git a/063 Unique Paths II.py b/python/063 Unique Paths II.py similarity index 100% rename from 063 Unique Paths II.py rename to python/063 Unique Paths II.py diff --git a/064 Minimum Path Sum.py b/python/064 Minimum Path Sum.py similarity index 100% rename from 064 Minimum Path Sum.py rename to python/064 Minimum Path Sum.py diff --git a/065 Valid Number.py b/python/065 Valid Number.py similarity index 100% rename from 065 Valid Number.py rename to python/065 Valid Number.py diff --git a/066 Plus One.py b/python/066 Plus One.py similarity index 100% rename from 066 Plus One.py rename to python/066 Plus One.py diff --git a/067 Add Binary.py b/python/067 Add Binary.py similarity index 100% rename from 067 Add Binary.py rename to python/067 Add Binary.py diff --git a/068 Text Justification.py b/python/068 Text Justification.py similarity index 100% rename from 068 Text Justification.py rename to python/068 Text Justification.py diff --git a/069 Sqrt(x).py b/python/069 Sqrt(x).py similarity index 100% rename from 069 Sqrt(x).py rename to python/069 Sqrt(x).py diff --git a/070 Climbing Stairs.py b/python/070 Climbing Stairs.py similarity index 100% rename from 070 Climbing Stairs.py rename to python/070 Climbing Stairs.py diff --git a/071 Simplify Path.py b/python/071 Simplify Path.py similarity index 100% rename from 071 Simplify Path.py rename to python/071 Simplify Path.py diff --git a/072 Edit Distance.py b/python/072 Edit Distance.py similarity index 100% rename from 072 Edit Distance.py rename to python/072 Edit Distance.py diff --git a/073 Set Matrix Zeroes.py b/python/073 Set Matrix Zeroes.py similarity index 100% rename from 073 Set Matrix Zeroes.py rename to python/073 Set Matrix Zeroes.py diff --git a/074 Search a 2D Matrix.py b/python/074 Search a 2D Matrix.py similarity index 100% rename from 074 Search a 2D Matrix.py rename to python/074 Search a 2D Matrix.py diff --git a/075 Sort Colors.py b/python/075 Sort Colors.py similarity index 100% rename from 075 Sort Colors.py rename to python/075 Sort Colors.py diff --git a/076 Minimum Window Substring.py b/python/076 Minimum Window Substring.py similarity index 100% rename from 076 Minimum Window Substring.py rename to python/076 Minimum Window Substring.py diff --git a/077 Combinations.py b/python/077 Combinations.py similarity index 100% rename from 077 Combinations.py rename to python/077 Combinations.py diff --git a/078 Subsets.py b/python/078 Subsets.py similarity index 100% rename from 078 Subsets.py rename to python/078 Subsets.py diff --git a/079 Word Search.py b/python/079 Word Search.py similarity index 100% rename from 079 Word Search.py rename to python/079 Word Search.py diff --git a/080 Remove Duplicates from Sorted Array II.py b/python/080 Remove Duplicates from Sorted Array II.py similarity index 100% rename from 080 Remove Duplicates from Sorted Array II.py rename to python/080 Remove Duplicates from Sorted Array II.py diff --git a/081 Search in Rotated Sorted Array II.py b/python/081 Search in Rotated Sorted Array II.py similarity index 100% rename from 081 Search in Rotated Sorted Array II.py rename to python/081 Search in Rotated Sorted Array II.py diff --git a/082 Remove Duplicates from Sorted List II.py b/python/082 Remove Duplicates from Sorted List II.py similarity index 100% rename from 082 Remove Duplicates from Sorted List II.py rename to python/082 Remove Duplicates from Sorted List II.py diff --git a/083 Remove Duplicates from Sorted List.py b/python/083 Remove Duplicates from Sorted List.py similarity index 100% rename from 083 Remove Duplicates from Sorted List.py rename to python/083 Remove Duplicates from Sorted List.py diff --git a/084 Largest Rectangle in Histogram.py b/python/084 Largest Rectangle in Histogram.py similarity index 100% rename from 084 Largest Rectangle in Histogram.py rename to python/084 Largest Rectangle in Histogram.py diff --git a/085 Maximal Rectangle.py b/python/085 Maximal Rectangle.py similarity index 100% rename from 085 Maximal Rectangle.py rename to python/085 Maximal Rectangle.py diff --git a/086 Partition List.py b/python/086 Partition List.py similarity index 100% rename from 086 Partition List.py rename to python/086 Partition List.py diff --git a/087 Scramble String.py b/python/087 Scramble String.py similarity index 100% rename from 087 Scramble String.py rename to python/087 Scramble String.py diff --git a/088 Merge Sorted Array.py b/python/088 Merge Sorted Array.py similarity index 100% rename from 088 Merge Sorted Array.py rename to python/088 Merge Sorted Array.py diff --git a/089 Gray Code.py b/python/089 Gray Code.py similarity index 100% rename from 089 Gray Code.py rename to python/089 Gray Code.py diff --git a/090 Subsets II.py b/python/090 Subsets II.py similarity index 100% rename from 090 Subsets II.py rename to python/090 Subsets II.py diff --git a/091 Decode Ways.py b/python/091 Decode Ways.py similarity index 100% rename from 091 Decode Ways.py rename to python/091 Decode Ways.py diff --git a/092 Reverse Linked List II.py b/python/092 Reverse Linked List II.py similarity index 100% rename from 092 Reverse Linked List II.py rename to python/092 Reverse Linked List II.py diff --git a/093 Restore IP Addresses.py b/python/093 Restore IP Addresses.py similarity index 100% rename from 093 Restore IP Addresses.py rename to python/093 Restore IP Addresses.py diff --git a/094 Binary Tree Inorder Traversal.py b/python/094 Binary Tree Inorder Traversal.py similarity index 100% rename from 094 Binary Tree Inorder Traversal.py rename to python/094 Binary Tree Inorder Traversal.py diff --git a/095 Unique Binary Search Trees II.py b/python/095 Unique Binary Search Trees II.py similarity index 100% rename from 095 Unique Binary Search Trees II.py rename to python/095 Unique Binary Search Trees II.py diff --git a/096 Unique Binary Search Trees.py b/python/096 Unique Binary Search Trees.py similarity index 100% rename from 096 Unique Binary Search Trees.py rename to python/096 Unique Binary Search Trees.py diff --git a/097 Interleaving String.py b/python/097 Interleaving String.py similarity index 100% rename from 097 Interleaving String.py rename to python/097 Interleaving String.py diff --git a/098 Validate Binary Search Tree.py b/python/098 Validate Binary Search Tree.py similarity index 100% rename from 098 Validate Binary Search Tree.py rename to python/098 Validate Binary Search Tree.py diff --git a/099 Recover Binary Search Tree.py b/python/099 Recover Binary Search Tree.py similarity index 100% rename from 099 Recover Binary Search Tree.py rename to python/099 Recover Binary Search Tree.py diff --git a/100 Same Tree.py b/python/100 Same Tree.py similarity index 100% rename from 100 Same Tree.py rename to python/100 Same Tree.py diff --git a/101 Symmetric Tree.py b/python/101 Symmetric Tree.py similarity index 100% rename from 101 Symmetric Tree.py rename to python/101 Symmetric Tree.py diff --git a/102 Binary Tree Level Order Traversal.py b/python/102 Binary Tree Level Order Traversal.py similarity index 100% rename from 102 Binary Tree Level Order Traversal.py rename to python/102 Binary Tree Level Order Traversal.py diff --git a/103 Binary Tree Zigzag Level Order Traversal.py b/python/103 Binary Tree Zigzag Level Order Traversal.py similarity index 100% rename from 103 Binary Tree Zigzag Level Order Traversal.py rename to python/103 Binary Tree Zigzag Level Order Traversal.py diff --git a/104 Maximum Depth of Binary Tree.py b/python/104 Maximum Depth of Binary Tree.py similarity index 100% rename from 104 Maximum Depth of Binary Tree.py rename to python/104 Maximum Depth of Binary Tree.py diff --git a/105 Construct Binary Tree from Preorder and Inorder Traversal.py b/python/105 Construct Binary Tree from Preorder and Inorder Traversal.py similarity index 100% rename from 105 Construct Binary Tree from Preorder and Inorder Traversal.py rename to python/105 Construct Binary Tree from Preorder and Inorder Traversal.py diff --git a/106 Construct Binary Tree from Inorder and Postorder Traversal.py b/python/106 Construct Binary Tree from Inorder and Postorder Traversal.py similarity index 100% rename from 106 Construct Binary Tree from Inorder and Postorder Traversal.py rename to python/106 Construct Binary Tree from Inorder and Postorder Traversal.py diff --git a/107 Binary Tree Level Order Traversal II.py b/python/107 Binary Tree Level Order Traversal II.py similarity index 100% rename from 107 Binary Tree Level Order Traversal II.py rename to python/107 Binary Tree Level Order Traversal II.py diff --git a/108 Convert Sorted Array to Binary Search Tree.py b/python/108 Convert Sorted Array to Binary Search Tree.py similarity index 100% rename from 108 Convert Sorted Array to Binary Search Tree.py rename to python/108 Convert Sorted Array to Binary Search Tree.py diff --git a/109 Convert Sorted List to Binary Search Tree.py b/python/109 Convert Sorted List to Binary Search Tree.py similarity index 100% rename from 109 Convert Sorted List to Binary Search Tree.py rename to python/109 Convert Sorted List to Binary Search Tree.py diff --git a/110 Balanced Binary Tree.py b/python/110 Balanced Binary Tree.py similarity index 100% rename from 110 Balanced Binary Tree.py rename to python/110 Balanced Binary Tree.py diff --git a/111 Minimum Depth of Binary Tree.py b/python/111 Minimum Depth of Binary Tree.py similarity index 100% rename from 111 Minimum Depth of Binary Tree.py rename to python/111 Minimum Depth of Binary Tree.py diff --git a/112 Path Sum.py b/python/112 Path Sum.py similarity index 100% rename from 112 Path Sum.py rename to python/112 Path Sum.py diff --git a/113 Path Sum II.py b/python/113 Path Sum II.py similarity index 100% rename from 113 Path Sum II.py rename to python/113 Path Sum II.py diff --git a/114 Flatten Binary Tree to Linked List.py b/python/114 Flatten Binary Tree to Linked List.py similarity index 100% rename from 114 Flatten Binary Tree to Linked List.py rename to python/114 Flatten Binary Tree to Linked List.py diff --git a/115 Distinct Subsequences.py b/python/115 Distinct Subsequences.py similarity index 100% rename from 115 Distinct Subsequences.py rename to python/115 Distinct Subsequences.py diff --git a/116 Populating Next Right Pointers in Each Node.py b/python/116 Populating Next Right Pointers in Each Node.py similarity index 100% rename from 116 Populating Next Right Pointers in Each Node.py rename to python/116 Populating Next Right Pointers in Each Node.py diff --git a/117 Populating Next Right Pointers in Each Node II.py b/python/117 Populating Next Right Pointers in Each Node II.py similarity index 100% rename from 117 Populating Next Right Pointers in Each Node II.py rename to python/117 Populating Next Right Pointers in Each Node II.py diff --git a/118 Pascal's Triangle.py b/python/118 Pascal's Triangle.py similarity index 100% rename from 118 Pascal's Triangle.py rename to python/118 Pascal's Triangle.py diff --git a/119 Pascal's Triangle II.py b/python/119 Pascal's Triangle II.py similarity index 100% rename from 119 Pascal's Triangle II.py rename to python/119 Pascal's Triangle II.py diff --git a/120 Triangle.py b/python/120 Triangle.py similarity index 100% rename from 120 Triangle.py rename to python/120 Triangle.py diff --git a/121 Best Time to Buy and Sell Stock.py b/python/121 Best Time to Buy and Sell Stock.py similarity index 100% rename from 121 Best Time to Buy and Sell Stock.py rename to python/121 Best Time to Buy and Sell Stock.py diff --git a/122 Best Time to Buy and Sell Stock II.py b/python/122 Best Time to Buy and Sell Stock II.py similarity index 100% rename from 122 Best Time to Buy and Sell Stock II.py rename to python/122 Best Time to Buy and Sell Stock II.py diff --git a/123 Best Time to Buy and Sell Stock III.py b/python/123 Best Time to Buy and Sell Stock III.py similarity index 100% rename from 123 Best Time to Buy and Sell Stock III.py rename to python/123 Best Time to Buy and Sell Stock III.py diff --git a/124 Binary Tree Maximum Path Sum.py b/python/124 Binary Tree Maximum Path Sum.py similarity index 100% rename from 124 Binary Tree Maximum Path Sum.py rename to python/124 Binary Tree Maximum Path Sum.py diff --git a/125 Valid Palindrome.py b/python/125 Valid Palindrome.py similarity index 100% rename from 125 Valid Palindrome.py rename to python/125 Valid Palindrome.py diff --git a/126 Word Ladder II.py b/python/126 Word Ladder II.py similarity index 100% rename from 126 Word Ladder II.py rename to python/126 Word Ladder II.py diff --git a/127 Word Ladder.py b/python/127 Word Ladder.py similarity index 100% rename from 127 Word Ladder.py rename to python/127 Word Ladder.py diff --git a/128 Longest Consecutive Sequence.py b/python/128 Longest Consecutive Sequence.py similarity index 100% rename from 128 Longest Consecutive Sequence.py rename to python/128 Longest Consecutive Sequence.py diff --git a/129 Sum Root to Leaf Numbers.py b/python/129 Sum Root to Leaf Numbers.py similarity index 100% rename from 129 Sum Root to Leaf Numbers.py rename to python/129 Sum Root to Leaf Numbers.py diff --git a/130 Surrounded Regions.py b/python/130 Surrounded Regions.py similarity index 100% rename from 130 Surrounded Regions.py rename to python/130 Surrounded Regions.py diff --git a/131 Palindrome Partitioning.py b/python/131 Palindrome Partitioning.py similarity index 100% rename from 131 Palindrome Partitioning.py rename to python/131 Palindrome Partitioning.py diff --git a/132 Palindrome Partitioning II.py b/python/132 Palindrome Partitioning II.py similarity index 100% rename from 132 Palindrome Partitioning II.py rename to python/132 Palindrome Partitioning II.py diff --git a/133 Clone Graph.py b/python/133 Clone Graph.py similarity index 100% rename from 133 Clone Graph.py rename to python/133 Clone Graph.py diff --git a/134 Gas Station.py b/python/134 Gas Station.py similarity index 100% rename from 134 Gas Station.py rename to python/134 Gas Station.py diff --git a/135 Candy.py b/python/135 Candy.py similarity index 100% rename from 135 Candy.py rename to python/135 Candy.py diff --git a/136 Single Number.py b/python/136 Single Number.py similarity index 100% rename from 136 Single Number.py rename to python/136 Single Number.py diff --git a/137 Single Number II.py b/python/137 Single Number II.py similarity index 100% rename from 137 Single Number II.py rename to python/137 Single Number II.py diff --git a/138 Copy List with Random Pointer.py b/python/138 Copy List with Random Pointer.py similarity index 100% rename from 138 Copy List with Random Pointer.py rename to python/138 Copy List with Random Pointer.py diff --git a/139 Word Break.py b/python/139 Word Break.py similarity index 100% rename from 139 Word Break.py rename to python/139 Word Break.py diff --git a/140 Word Break II.py b/python/140 Word Break II.py similarity index 100% rename from 140 Word Break II.py rename to python/140 Word Break II.py diff --git a/141 Linked List Cycle.py b/python/141 Linked List Cycle.py similarity index 100% rename from 141 Linked List Cycle.py rename to python/141 Linked List Cycle.py diff --git a/142 Linked List Cycle II.py b/python/142 Linked List Cycle II.py similarity index 100% rename from 142 Linked List Cycle II.py rename to python/142 Linked List Cycle II.py diff --git a/143 Reorder List.py b/python/143 Reorder List.py similarity index 100% rename from 143 Reorder List.py rename to python/143 Reorder List.py diff --git a/144 Binary Tree Preorder Traversal.py b/python/144 Binary Tree Preorder Traversal.py similarity index 100% rename from 144 Binary Tree Preorder Traversal.py rename to python/144 Binary Tree Preorder Traversal.py diff --git a/145 Binary Tree Postorder Traversal.py b/python/145 Binary Tree Postorder Traversal.py similarity index 100% rename from 145 Binary Tree Postorder Traversal.py rename to python/145 Binary Tree Postorder Traversal.py diff --git a/146 LRU Cache.py b/python/146 LRU Cache.py similarity index 100% rename from 146 LRU Cache.py rename to python/146 LRU Cache.py diff --git a/147 Insertion Sort List.py b/python/147 Insertion Sort List.py similarity index 100% rename from 147 Insertion Sort List.py rename to python/147 Insertion Sort List.py diff --git a/149 Max Points on a Line.py b/python/149 Max Points on a Line.py similarity index 100% rename from 149 Max Points on a Line.py rename to python/149 Max Points on a Line.py diff --git a/150 Evaluate Reverse Polish Notation.py b/python/150 Evaluate Reverse Polish Notation.py similarity index 100% rename from 150 Evaluate Reverse Polish Notation.py rename to python/150 Evaluate Reverse Polish Notation.py diff --git a/151 Reverse Words in a String.py b/python/151 Reverse Words in a String.py similarity index 100% rename from 151 Reverse Words in a String.py rename to python/151 Reverse Words in a String.py diff --git a/152 Maximum Product Subarray.py b/python/152 Maximum Product Subarray.py similarity index 100% rename from 152 Maximum Product Subarray.py rename to python/152 Maximum Product Subarray.py diff --git a/153 Find Minimum in Rotated Sorted Array.py b/python/153 Find Minimum in Rotated Sorted Array.py similarity index 100% rename from 153 Find Minimum in Rotated Sorted Array.py rename to python/153 Find Minimum in Rotated Sorted Array.py diff --git a/155 Min Stack.py b/python/155 Min Stack.py similarity index 100% rename from 155 Min Stack.py rename to python/155 Min Stack.py diff --git a/160 Intersection of Two Linked Lists.py b/python/160 Intersection of Two Linked Lists.py similarity index 100% rename from 160 Intersection of Two Linked Lists.py rename to python/160 Intersection of Two Linked Lists.py diff --git a/162 Find Peak Element.py b/python/162 Find Peak Element.py similarity index 100% rename from 162 Find Peak Element.py rename to python/162 Find Peak Element.py diff --git a/164 Maximum Gap.py b/python/164 Maximum Gap.py similarity index 100% rename from 164 Maximum Gap.py rename to python/164 Maximum Gap.py diff --git a/165 Compare Version Numbers.py b/python/165 Compare Version Numbers.py similarity index 100% rename from 165 Compare Version Numbers.py rename to python/165 Compare Version Numbers.py diff --git a/166 Fraction to Recurring Decimal.py b/python/166 Fraction to Recurring Decimal.py similarity index 100% rename from 166 Fraction to Recurring Decimal.py rename to python/166 Fraction to Recurring Decimal.py diff --git a/168 Excel Sheet Column Title.py b/python/168 Excel Sheet Column Title.py similarity index 100% rename from 168 Excel Sheet Column Title.py rename to python/168 Excel Sheet Column Title.py diff --git a/169 Majority Element.py b/python/169 Majority Element.py similarity index 100% rename from 169 Majority Element.py rename to python/169 Majority Element.py diff --git a/171 Excel Sheet Column Number.py b/python/171 Excel Sheet Column Number.py similarity index 100% rename from 171 Excel Sheet Column Number.py rename to python/171 Excel Sheet Column Number.py diff --git a/172 Factorial Trailing Zeroes.py b/python/172 Factorial Trailing Zeroes.py similarity index 100% rename from 172 Factorial Trailing Zeroes.py rename to python/172 Factorial Trailing Zeroes.py diff --git a/173 Binary Search Tree Iterator.py b/python/173 Binary Search Tree Iterator.py similarity index 100% rename from 173 Binary Search Tree Iterator.py rename to python/173 Binary Search Tree Iterator.py diff --git a/174 Dungeon Game.py b/python/174 Dungeon Game.py similarity index 100% rename from 174 Dungeon Game.py rename to python/174 Dungeon Game.py diff --git a/179 Largest Number.py b/python/179 Largest Number.py similarity index 100% rename from 179 Largest Number.py rename to python/179 Largest Number.py diff --git a/189 Rotate Array.py b/python/189 Rotate Array.py similarity index 100% rename from 189 Rotate Array.py rename to python/189 Rotate Array.py diff --git a/190 Reverse Bits.py b/python/190 Reverse Bits.py similarity index 100% rename from 190 Reverse Bits.py rename to python/190 Reverse Bits.py diff --git a/191 Number of 1 Bits.py b/python/191 Number of 1 Bits.py similarity index 100% rename from 191 Number of 1 Bits.py rename to python/191 Number of 1 Bits.py diff --git a/198 House Robber.py b/python/198 House Robber.py similarity index 100% rename from 198 House Robber.py rename to python/198 House Robber.py diff --git a/199 Binary Tree Right Side View.py b/python/199 Binary Tree Right Side View.py similarity index 100% rename from 199 Binary Tree Right Side View.py rename to python/199 Binary Tree Right Side View.py diff --git a/200 Number of Islands.py b/python/200 Number of Islands.py similarity index 100% rename from 200 Number of Islands.py rename to python/200 Number of Islands.py diff --git a/201 Bitwise AND of Numbers Range.py b/python/201 Bitwise AND of Numbers Range.py similarity index 100% rename from 201 Bitwise AND of Numbers Range.py rename to python/201 Bitwise AND of Numbers Range.py diff --git a/202 Happy Number.py b/python/202 Happy Number.py similarity index 100% rename from 202 Happy Number.py rename to python/202 Happy Number.py diff --git a/203 Remove Linked List Elements.py b/python/203 Remove Linked List Elements.py similarity index 100% rename from 203 Remove Linked List Elements.py rename to python/203 Remove Linked List Elements.py diff --git a/204 Count Primes.py b/python/204 Count Primes.py similarity index 100% rename from 204 Count Primes.py rename to python/204 Count Primes.py diff --git a/205 Isomorphic Strings.py b/python/205 Isomorphic Strings.py similarity index 100% rename from 205 Isomorphic Strings.py rename to python/205 Isomorphic Strings.py diff --git a/206 Reverse Linked List.py b/python/206 Reverse Linked List.py similarity index 100% rename from 206 Reverse Linked List.py rename to python/206 Reverse Linked List.py diff --git a/217 Contains Duplicate.py b/python/217 Contains Duplicate.py similarity index 100% rename from 217 Contains Duplicate.py rename to python/217 Contains Duplicate.py diff --git a/219 Contains Duplicate II.py b/python/219 Contains Duplicate II.py similarity index 100% rename from 219 Contains Duplicate II.py rename to python/219 Contains Duplicate II.py diff --git a/233 Number of Digit One.py b/python/233 Number of Digit One.py similarity index 100% rename from 233 Number of Digit One.py rename to python/233 Number of Digit One.py diff --git a/234 Palindrome Linked List.py b/python/234 Palindrome Linked List.py similarity index 100% rename from 234 Palindrome Linked List.py rename to python/234 Palindrome Linked List.py diff --git a/237 Delete Node in a Linked List.py b/python/237 Delete Node in a Linked List.py similarity index 100% rename from 237 Delete Node in a Linked List.py rename to python/237 Delete Node in a Linked List.py diff --git a/238 Product of Array Except Self.py b/python/238 Product of Array Except Self.py similarity index 100% rename from 238 Product of Array Except Self.py rename to python/238 Product of Array Except Self.py diff --git a/242 Valid Anagram.py b/python/242 Valid Anagram.py similarity index 100% rename from 242 Valid Anagram.py rename to python/242 Valid Anagram.py From bca161017cc446590a1886c61286b6bfa7136179 Mon Sep 17 00:00:00 2001 From: Shen Jie Date: Sat, 15 Apr 2017 09:37:53 +0800 Subject: [PATCH 07/53] update readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3b2ec4a..1234409 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -# LeetCode-Python +# leetcode-share [![Language](https://img.shields.io/badge/python-3.5-blue.svg)](https://www.python.org) -I created this repository to sharpen my Python skills by solving LeetCode problems. +This repository shares my leetcode problems solving experience. The first edition is written in Python3, and now I am working on resolving them with Java8. There are articles describing the solution. For further information, please see the Articles part. ## Problems From 369877258ce00327b0f27f81b936ad4a33396f42 Mon Sep 17 00:00:00 2001 From: Shen Jie Date: Sun, 16 Apr 2017 20:58:48 +0800 Subject: [PATCH 08/53] java 2/19/21/23/24/25 --- java/_002AddTwoNumbers.java | 52 ++++++++++++++++++++++++ java/_019RemoveNthNodeFromEndOfList.java | 29 +++++++++++++ java/_021MergeTwoSortedLists.java | 26 ++++++++++++ java/_023MergekSortedLists.java | 26 ++++++++++++ java/_024SwapNodesInPairs.java | 26 ++++++++++++ java/_25ReverNodesInkGroup.java | 45 ++++++++++++++++++++ 6 files changed, 204 insertions(+) create mode 100644 java/_002AddTwoNumbers.java create mode 100644 java/_019RemoveNthNodeFromEndOfList.java create mode 100644 java/_021MergeTwoSortedLists.java create mode 100644 java/_023MergekSortedLists.java create mode 100644 java/_024SwapNodesInPairs.java create mode 100644 java/_25ReverNodesInkGroup.java diff --git a/java/_002AddTwoNumbers.java b/java/_002AddTwoNumbers.java new file mode 100644 index 0000000..0774b74 --- /dev/null +++ b/java/_002AddTwoNumbers.java @@ -0,0 +1,52 @@ +/** + * You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list. + * You may assume the two numbers do not contain any leading zero, except the number 0 itself. + *

+ * Input: (2 -> 4 -> 3) + (5 -> 6 -> 4) + * Output: 7 -> 0 -> 8 + *

+ * Created by drfish on 16/04/2017. + */ + +/** + * Definition for singly-linked list. + */ +class ListNode { + int val; + ListNode next; + + ListNode(int x) { + val = x; + } +} + +public class _002AddTwoNumbers { + public ListNode addTwoNumbers(ListNode l1, ListNode l2) { + ListNode result = new ListNode(0); + ListNode cur = result; + while (l1 != null || l2 != null) { + cur.val += addTwoNodes(l1, l2); + if (cur.val >= 10) { + cur.val -= 10; + cur.next = new ListNode(1); + } else { + if (l1 != null && l1.next != null || l2 != null && l2.next != null) + cur.next = new ListNode(0); + } + cur = cur.next; + if (l1 != null) + l1 = l1.next; + if (l2 != null) + l2 = l2.next; + } + return result; + } + + private int addTwoNodes(ListNode n1, ListNode n2) { + if (n1 == null) + return n2.val; + if (n2 == null) + return n1.val; + return n1.val + n2.val; + } +} diff --git a/java/_019RemoveNthNodeFromEndOfList.java b/java/_019RemoveNthNodeFromEndOfList.java new file mode 100644 index 0000000..fa96083 --- /dev/null +++ b/java/_019RemoveNthNodeFromEndOfList.java @@ -0,0 +1,29 @@ +/** + * Given a linked list, remove the nth node from the end of list and return its head. + * For example, + * Given linked list: 1->2->3->4->5, and n = 2. + * After removing the second node from the end, the linked list becomes 1->2->3->5. + *

+ * Note: + * Given n will always be valid. + * Try to do this in one pass. + *

+ * Created by drfish on 16/04/2017. + */ + +public class _019RemoveNthNodeFromEndOfList { + public ListNode removeNthFromEnd(ListNode head, int n) { + ListNode dummy = new ListNode(-1); + dummy.next = head; + ListNode fast = dummy; + ListNode slow = dummy; + for (int i = 0; i < n; i++) + fast = fast.next; + while (fast.next != null) { + fast = fast.next; + slow = slow.next; + } + slow.next = slow.next.next; + return dummy.next; + } +} \ No newline at end of file diff --git a/java/_021MergeTwoSortedLists.java b/java/_021MergeTwoSortedLists.java new file mode 100644 index 0000000..eceb76b --- /dev/null +++ b/java/_021MergeTwoSortedLists.java @@ -0,0 +1,26 @@ +/** + * Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. + *

+ * Created by drfish on 16/04/2017. + */ +public class _021MergeTwoSortedLists { + public ListNode mergeTwoLists(ListNode l1, ListNode l2) { + ListNode dummy = new ListNode(-1); + ListNode head = dummy; + while (l1 != null && l2 != null) { + if (l1.val < l2.val) { + dummy.next = l1; + l1 = l1.next; + } else { + dummy.next = l2; + l2 = l2.next; + } + dummy = dummy.next; + } + if (l1 == null) + dummy.next = l2; + if (l2 == null) + dummy.next = l1; + return head.next; + } +} diff --git a/java/_023MergekSortedLists.java b/java/_023MergekSortedLists.java new file mode 100644 index 0000000..f299b58 --- /dev/null +++ b/java/_023MergekSortedLists.java @@ -0,0 +1,26 @@ +import java.util.PriorityQueue; + +/** + * Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. + *

+ * Created by drfish on 16/04/2017. + */ +public class _023MergekSortedLists { + public ListNode mergeKLists(ListNode[] lists) { + PriorityQueue nodesHeap = new PriorityQueue((n1, n2) -> (n1.val - n2.val)); + for (ListNode node : lists) { + if (node != null) + nodesHeap.add(node); + } + ListNode dummy = new ListNode(-1); + ListNode head = dummy; + while (!nodesHeap.isEmpty()) { + ListNode node = nodesHeap.poll(); + if (node.next != null) + nodesHeap.add(node.next); + dummy.next = node; + dummy = dummy.next; + } + return head.next; + } +} diff --git a/java/_024SwapNodesInPairs.java b/java/_024SwapNodesInPairs.java new file mode 100644 index 0000000..37d26b5 --- /dev/null +++ b/java/_024SwapNodesInPairs.java @@ -0,0 +1,26 @@ +/** + * Given a linked list, swap every two adjacent nodes and return its head. + *

+ * For example, + * Given 1->2->3->4, you should return the list as 2->1->4->3. + *

+ * Your algorithm should use only constant space. You may not modify the values in the list, only nodes itself can be changed. + *

+ * Created by drfish on 16/04/2017. + */ +public class _024SwapNodesInPairs { + public ListNode swapPairs(ListNode head) { + if (head == null || head.next == null) + return head; + ListNode dummy = new ListNode(-1); + dummy.next = head; + for (ListNode prev = dummy, cur = prev.next, next = cur.next; + next != null; + prev = cur, cur = cur.next, next = cur != null ? cur.next : null) { + prev.next = next; + cur.next = next.next; + next.next = cur; + } + return dummy.next; + } +} diff --git a/java/_25ReverNodesInkGroup.java b/java/_25ReverNodesInkGroup.java new file mode 100644 index 0000000..8b3f9c9 --- /dev/null +++ b/java/_25ReverNodesInkGroup.java @@ -0,0 +1,45 @@ +/** + * Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. + *

+ * k is a positive integer and is less than or equal to the length of the linked list. If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is. + *

+ * You may not alter the values in the nodes, only nodes itself may be changed. + *

+ * Only constant memory is allowed. + *

+ * For example, + * Given this linked list: 1->2->3->4->5 + *

+ * For k = 2, you should return: 2->1->4->3->5 + *

+ * For k = 3, you should return: 3->2->1->4->5 + *

+ * Created by drfish on 16/04/2017. + */ +public class _25ReverNodesInkGroup { + public ListNode reverseKGroup(ListNode head, int k) { + if (head == null || k <= 1) + return head; + ListNode dummy = new ListNode(-1); + dummy.next = head; + for (ListNode prev = dummy, end = head; end != null; end = prev.next) { + for (int i = 1; i < k && end != null; i++) + end = end.next; + if (end == null) + break; + prev = reverse(prev, prev.next, end); + } + return dummy.next; + } + + private ListNode reverse(ListNode prev, ListNode start, ListNode end) { + ListNode endNext = end.next; + for (ListNode p = start, cur = p.next, next = cur.next; + cur != endNext; + p = cur, cur = next, next = next != null ? next.next : null) + cur.next = p; + start.next = endNext; + prev.next = end; + return start; + } +} From 17a7a287b056f9d38bfc4b6c1e17a36a4781c193 Mon Sep 17 00:00:00 2001 From: Shen Jie Date: Sun, 16 Apr 2017 21:02:35 +0800 Subject: [PATCH 09/53] update gitignore --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index ba74660..8f49248 100644 --- a/.gitignore +++ b/.gitignore @@ -55,3 +55,7 @@ docs/_build/ # PyBuilder target/ + +# IntelliJ Idea +out/ +*.iml From 708f7a3bb09b22c2ffab30335ad1dd6a6fa1bf40 Mon Sep 17 00:00:00 2001 From: Shen Jie Date: Mon, 1 May 2017 16:00:22 +0800 Subject: [PATCH 10/53] Add MIT license --- LICENSE | 21 +++++++++++++++++++++ README.md | 23 +++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..5837877 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 Drfish + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 1234409..b0ad448 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # leetcode-share [![Language](https://img.shields.io/badge/python-3.5-blue.svg)](https://www.python.org) +[![License](https://img.shields.io/dub/l/vibe-d.svg)](https://opensource.org/licenses/MIT) This repository shares my leetcode problems solving experience. The first edition is written in Python3, and now I am working on resolving them with Java8. There are articles describing the solution. For further information, please see the Articles part. @@ -17,3 +18,25 @@ You are welcome if you have any question or suggestion. There are articles about each problem, describing how I solve that problem. You can visit them on [GitBook](https://shenjie1993.gitbooks.io/leetcode-python/content/) or [CSDN](http://blog.csdn.net/column/details/leetcode-python.html). It is a pity that they are only in Chinese. + +## MIT License + +Copyright (c) 2017 Drfish + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file From 71e646e18263fc263b4447346e609625e120f25e Mon Sep 17 00:00:00 2001 From: Shen Jie Date: Tue, 2 May 2017 15:58:18 +0800 Subject: [PATCH 11/53] TAG file --- TAG.md | 947 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 947 insertions(+) create mode 100644 TAG.md diff --git a/TAG.md b/TAG.md new file mode 100644 index 0000000..3691dee --- /dev/null +++ b/TAG.md @@ -0,0 +1,947 @@ +# Tag + +- [Array](https://github.com/gavinfish/leetcode-share#array) +- [Hash Table](https://github.com/gavinfish/leetcode-share#hash-table) +- [Linked List](https://github.com/gavinfish/leetcode-share#linked-list) +- [Math](https://github.com/gavinfish/leetcode-share#math) +- [Two Pointers](https://github.com/gavinfish/leetcode-share#two-pointers) +- [String](https://github.com/gavinfish/leetcode-share#string) +- [Binary Search](https://github.com/gavinfish/leetcode-share#binary-search) +- [Divide and Conquer](https://github.com/gavinfish/leetcode-share#divide-and-conquer) +- [Dynamic Programming](https://github.com/gavinfish/leetcode-share#dynamic-programming) +- [Backtracking](https://github.com/gavinfish/leetcode-share#backtracking) +- [Stack](https://github.com/gavinfish/leetcode-share#stack) +- [Heap](https://github.com/gavinfish/leetcode-share#heap) +- [Tree](https://github.com/gavinfish/leetcode-share#tree) +- [Depth-first Search](https://github.com/gavinfish/leetcode-share#depth-first-search) +- [Breadth-first Search](https://github.com/gavinfish/leetcode-share#breadth-first-search) +- [Union Find](https://github.com/gavinfish/leetcode-share#union-find) +- [Graph](https://github.com/gavinfish/leetcode-share#graph) +- [Design](https://github.com/gavinfish/leetcode-share#design) +- [Topological Sort](https://github.com/gavinfish/leetcode-share#topological-sort) +- [Trie](https://github.com/gavinfish/leetcode-share#trie) +- [Binary Indexed Tree](https://github.com/gavinfish/leetcode-share#binary-indexed-tree) +- [Segment Tree](https://github.com/gavinfish/leetcode-share#segment-tree) +- [Binary Search Tree](https://github.com/gavinfish/leetcode-share#binary-search-tree) +- [Recursion](https://github.com/gavinfish/leetcode-share#recursion) +- [Brainteaser](https://github.com/gavinfish/leetcode-share#brainteaser) +- [Memoization](https://github.com/gavinfish/leetcode-share#memoization) +- [Queue](https://github.com/gavinfish/leetcode-share#queue) +- [Minimax](https://github.com/gavinfish/leetcode-share#minimax) +- [Reservoir Sampling](https://github.com/gavinfish/leetcode-share#reservoir-sampling) + +## Array + +| # | Title | Solution | Difficulty | Note | +|-----|---------------- | --------------- | --------------- | --------------- | +|1|Two Sum|[Python](python/001 Two Sum.py) [Java]()|Easy|| +|4|Median of Two Sorted Arrays|[Python](python/004 Median of Two Sorted Arrays.py) [Java]()|Hard|| +|11|Container With Most Water|[Python](python/011 Container With Most Water.py) [Java]()|Medium|| +|15|3Sum|[Python](python/015 3Sum.py) [Java]()|Medium|| +|16|3Sum Closest|[Python](python/016 3Sum Closest.py) [Java]()|Medium|| +|18|4Sum|[Python](python/018 4Sum.py) [Java]()|Medium|| +|26|Remove Duplicates from Sorted Array|[Python](python/026 Remove Duplicates from Sorted Array.py) [Java]()|Easy|| +|27|Remove Element|[Python](python/027 Remove Element.py) [Java]()|Easy|| +|31|Next Permutation|[Python](python/031 Next Permutation.py) [Java]()|Medium|| +|33|Search in Rotated Sorted Array|[Python](python/033 Search in Rotated Sorted Array.py) [Java]()|Medium|| +|34|Search for a Range|[Python](python/034 Search for a Range.py) [Java]()|Medium|| +|35|Search Insert Position|[Python](python/035 Search Insert Position.py) [Java]()|Easy|| +|39|Combination Sum|[Python](python/039 Combination Sum.py) [Java]()|Medium|| +|40|Combination Sum II|[Python](python/040 Combination Sum II.py) [Java]()|Medium|| +|41|First Missing Positive|[Python](python/041 First Missing Positive.py) [Java]()|Hard|| +|42|Trapping Rain Water|[Python](python/042 Trapping Rain Water.py) [Java]()|Hard|| +|45|Jump Game II|[Python](python/045 Jump Game II.py) [Java]()|Hard|| +|48|Rotate Image|[Python](python/048 Rotate Image.py) [Java]()|Medium|| +|53|Maximum Subarray|[Python](python/053 Maximum Subarray.py) [Java]()|Easy|| +|54|Spiral Matrix|[Python](python/054 Spiral Matrix.py) [Java]()|Medium|| +|55|Jump Game|[Python](python/055 Jump Game.py) [Java]()|Medium|| +|56|Merge Intervals|[Python](python/056 Merge Intervals.py) [Java]()|Medium|| +|57|Insert Interval|[Python](python/057 Insert Interval.py) [Java]()|Hard|| +|59|Spiral Matrix II|[Python](python/059 Spiral Matrix II.py) [Java]()|Medium|| +|62|Unique Paths|[Python](python/062 Unique Paths.py) [Java]()|Medium|| +|63|Unique Paths II|[Python](python/063 Unique Paths II.py) [Java]()|Medium|| +|64|Minimum Path Sum|[Python](python/064 Minimum Path Sum.py) [Java]()|Medium|| +|66|Plus One|[Python](python/066 Plus One.py) [Java]()|Easy|| +|73|Set Matrix Zeroes|[Python](python/073 Set Matrix Zeroes.py) [Java]()|Medium|| +|74|Search a 2D Matrix|[Python](python/074 Search a 2D Matrix.py) [Java]()|Medium|| +|75|Sort Colors|[Python](python/075 Sort Colors.py) [Java]()|Medium|| +|78|Subsets|[Python](python/078 Subsets.py) [Java]()|Medium|| +|79|Word Search|[Python](python/079 Word Search.py) [Java]()|Medium|| +|80|Remove Duplicates from Sorted Array II|[Python](python/080 Remove Duplicates from Sorted Array II.py) [Java]()|Medium|| +|81|Search in Rotated Sorted Array II|[Python](python/081 Search in Rotated Sorted Array II.py) [Java]()|Medium|| +|84|Largest Rectangle in Histogram|[Python](python/084 Largest Rectangle in Histogram.py) [Java]()|Hard|| +|85|Maximal Rectangle|[Python](python/085 Maximal Rectangle.py) [Java]()|Hard|| +|88|Merge Sorted Array|[Python](python/088 Merge Sorted Array.py) [Java]()|Easy|| +|90|Subsets II|[Python](python/090 Subsets II.py) [Java]()|Medium|| +|105|Construct Binary Tree from Preorder and Inorder Traversal|[Python](python/105 Construct Binary Tree from Preorder and Inorder Traversal.py) [Java]()|Medium|| +|106|Construct Binary Tree from Inorder and Postorder Traversal|[Python](python/106 Construct Binary Tree from Inorder and Postorder Traversal.py) [Java]()|Medium|| +|118|Pascal's Triangle|[Python](python/118 Pascal's Triangle.py) [Java]()|Easy|| +|119|Pascal's Triangle II|[Python](python/119 Pascal's Triangle II.py) [Java]()|Easy|| +|120|Triangle|[Python](python/120 Triangle.py) [Java]()|Medium|| +|121|Best Time to Buy and Sell Stock|[Python](python/121 Best Time to Buy and Sell Stock.py) [Java]()|Easy|| +|122|Best Time to Buy and Sell Stock II|[Python](python/122 Best Time to Buy and Sell Stock II.py) [Java]()|Easy|| +|123|Best Time to Buy and Sell Stock III|[Python](python/123 Best Time to Buy and Sell Stock III.py) [Java]()|Hard|| +|126|Word Ladder II|[Python](python/126 Word Ladder II.py) [Java]()|Hard|| +|128|Longest Consecutive Sequence|[Python](python/128 Longest Consecutive Sequence.py) [Java]()|Hard|| +|152|Maximum Product Subarray|[Python](python/152 Maximum Product Subarray.py) [Java]()|Medium|| +|153|Find Minimum in Rotated Sorted Array|[Python](python/153 Find Minimum in Rotated Sorted Array.py) [Java]()|Medium|| +|154|Find Minimum in Rotated Sorted Array II|[Python](python/154 Find Minimum in Rotated Sorted Array II.py) [Java]()|Hard|| +|162|Find Peak Element|[Python](python/162 Find Peak Element.py) [Java]()|Medium|| +|163|Missing Ranges|[Python](python/163 Missing Ranges.py) [Java]()|Medium|| +|167|Two Sum II - Input array is sorted|[Python](python/167 Two Sum II - Input array is sorted.py) [Java]()|Easy|| +|169|Majority Element|[Python](python/169 Majority Element.py) [Java]()|Easy|| +|189|Rotate Array|[Python](python/189 Rotate Array.py) [Java]()|Easy|| +|209|Minimum Size Subarray Sum|[Python](python/209 Minimum Size Subarray Sum.py) [Java]()|Medium|| +|216|Combination Sum III|[Python](python/216 Combination Sum III.py) [Java]()|Medium|| +|217|Contains Duplicate|[Python](python/217 Contains Duplicate.py) [Java]()|Easy|| +|219|Contains Duplicate II|[Python](python/219 Contains Duplicate II.py) [Java]()|Easy|| +|228|Summary Ranges|[Python](python/228 Summary Ranges.py) [Java]()|Medium|| +|229|Majority Element II|[Python](python/229 Majority Element II.py) [Java]()|Medium|| +|238|Product of Array Except Self|[Python](python/238 Product of Array Except Self.py) [Java]()|Medium|| +|243|Shortest Word Distance|[Python](python/243 Shortest Word Distance.py) [Java]()|Easy|| +|245|Shortest Word Distance III|[Python](python/245 Shortest Word Distance III.py) [Java]()|Medium|| +|259|3Sum Smaller|[Python](python/259 3Sum Smaller.py) [Java]()|Medium|| +|268|Missing Number|[Python](python/268 Missing Number.py) [Java]()|Easy|| +|277|Find the Celebrity|[Python](python/277 Find the Celebrity.py) [Java]()|Medium|| +|280|Wiggle Sort|[Python](python/280 Wiggle Sort.py) [Java]()|Medium|| +|283|Move Zeroes|[Python](python/283 Move Zeroes.py) [Java]()|Easy|| +|287|Find the Duplicate Number|[Python](python/287 Find the Duplicate Number.py) [Java]()|Medium|| +|289|Game of Life|[Python](python/289 Game of Life.py) [Java]()|Medium|| +|370|Range Addition|[Python](python/370 Range Addition.py) [Java]()|Medium|| +|380|Insert Delete GetRandom O(1)|[Python](python/380 Insert Delete GetRandom O(1).py) [Java]()|Medium|| +|381|Insert Delete GetRandom O(1) - Duplicates allowed|[Python](python/381 Insert Delete GetRandom O(1) - Duplicates allowed.py) [Java]()|Hard|| +|414|Third Maximum Number|[Python](python/414 Third Maximum Number.py) [Java]()|Easy|| +|442|Find All Duplicates in an Array|[Python](python/442 Find All Duplicates in an Array.py) [Java]()|Medium|| +|448|Find All Numbers Disappeared in an Array|[Python](python/448 Find All Numbers Disappeared in an Array.py) [Java]()|Easy|| +|485|Max Consecutive Ones|[Python](python/485 Max Consecutive Ones.py) [Java]()|Easy|| +|495|Teemo Attacking|[Python](python/495 Teemo Attacking.py) [Java]()|Medium|| +|531|Lonely Pixel I|[Python](python/531 Lonely Pixel I.py) [Java]()|Medium|| +|532|K-diff Pairs in an Array|[Python](python/532 K-diff Pairs in an Array.py) [Java]()|Easy|| +|533|Lonely Pixel II|[Python](python/533 Lonely Pixel II.py) [Java]()|Medium|| +|548|Split Array with Equal Sum|[Python](python/548 Split Array with Equal Sum.py) [Java]()|Medium|| +|560|Subarray Sum Equals K|[Python](python/560 Subarray Sum Equals K.py) [Java]()|Medium|| +|561|Array Partition I|[Python](python/561 Array Partition I.py) [Java]()|Easy|| +|562|Longest Line of Consecutive One in Matrix|[Python](python/562 Longest Line of Consecutive One in Matrix.py) [Java]()|Medium|| +|566|Reshape the Matrix|[Python](python/566 Reshape the Matrix.py) [Java]()|Easy|| + +## Hash Table + +| # | Title | Solution | Difficulty | Note | +|-----|---------------- | --------------- | --------------- | --------------- | +|1|Two Sum|[Python](python/001 Two Sum.py) [Java]()|Easy|| +|3|Longest Substring Without Repeating Characters|[Python](python/003 Longest Substring Without Repeating Characters.py) [Java]()|Medium|| +|18|4Sum|[Python](python/018 4Sum.py) [Java]()|Medium|| +|30|Substring with Concatenation of All Words|[Python](python/030 Substring with Concatenation of All Words.py) [Java]()|Hard|| +|36|Valid Sudoku|[Python](python/036 Valid Sudoku.py) [Java]()|Medium|| +|37|Sudoku Solver|[Python](python/037 Sudoku Solver.py) [Java]()|Hard|| +|49|Group Anagrams|[Python](python/049 Group Anagrams.py) [Java]()|Medium|| +|76|Minimum Window Substring|[Python](python/076 Minimum Window Substring.py) [Java]()|Hard|| +|85|Maximal Rectangle|[Python](python/085 Maximal Rectangle.py) [Java]()|Hard|| +|94|Binary Tree Inorder Traversal|[Python](python/094 Binary Tree Inorder Traversal.py) [Java]()|Medium|| +|136|Single Number|[Python](python/136 Single Number.py) [Java]()|Easy|| +|138|Copy List with Random Pointer|[Python](python/138 Copy List with Random Pointer.py) [Java]()|Medium|| +|149|Max Points on a Line|[Python](python/149 Max Points on a Line.py) [Java]()|Hard|| +|159|Longest Substring with At Most Two Distinct Characters|[Python](python/159 Longest Substring with At Most Two Distinct Characters.py) [Java]()|Hard|| +|166|Fraction to Recurring Decimal|[Python](python/166 Fraction to Recurring Decimal.py) [Java]()|Medium|| +|170|Two Sum III - Data structure design|[Python](python/170 Two Sum III - Data structure design.py) [Java]()|Easy|| +|187|Repeated DNA Sequences|[Python](python/187 Repeated DNA Sequences.py) [Java]()|Medium|| +|202|Happy Number|[Python](python/202 Happy Number.py) [Java]()|Easy|| +|204|Count Primes|[Python](python/204 Count Primes.py) [Java]()|Easy|| +|205|Isomorphic Strings|[Python](python/205 Isomorphic Strings.py) [Java]()|Easy|| +|217|Contains Duplicate|[Python](python/217 Contains Duplicate.py) [Java]()|Easy|| +|219|Contains Duplicate II|[Python](python/219 Contains Duplicate II.py) [Java]()|Easy|| +|242|Valid Anagram|[Python](python/242 Valid Anagram.py) [Java]()|Easy|| +|244|Shortest Word Distance II|[Python](python/244 Shortest Word Distance II.py) [Java]()|Medium|| +|246|Strobogrammatic Number|[Python](python/246 Strobogrammatic Number.py) [Java]()|Easy|| +|249|Group Shifted Strings|[Python](python/249 Group Shifted Strings.py) [Java]()|Medium|| +|266|Palindrome Permutation|[Python](python/266 Palindrome Permutation.py) [Java]()|Easy|| +|274|H-Index|[Python](python/274 H-Index.py) [Java]()|Medium|| +|288|Unique Word Abbreviation|[Python](python/288 Unique Word Abbreviation.py) [Java]()|Medium|| +|290|Word Pattern|[Python](python/290 Word Pattern.py) [Java]()|Easy|| +|299|Bulls and Cows|[Python](python/299 Bulls and Cows.py) [Java]()|Medium|| +|311|Sparse Matrix Multiplication|[Python](python/311 Sparse Matrix Multiplication.py) [Java]()|Medium|| +|314|Binary Tree Vertical Order Traversal|[Python](python/314 Binary Tree Vertical Order Traversal.py) [Java]()|Medium|| +|325|Maximum Size Subarray Sum Equals k|[Python](python/325 Maximum Size Subarray Sum Equals k.py) [Java]()|Medium|| +|336|Palindrome Pairs|[Python](python/336 Palindrome Pairs.py) [Java]()|Hard|| +|340|Longest Substring with At Most K Distinct Characters|[Python](python/340 Longest Substring with At Most K Distinct Characters.py) [Java]()|Hard|| +|347|Top K Frequent Elements|[Python](python/347 Top K Frequent Elements.py) [Java]()|Medium|| +|349|Intersection of Two Arrays|[Python](python/349 Intersection of Two Arrays.py) [Java]()|Easy|| +|350|Intersection of Two Arrays II|[Python](python/350 Intersection of Two Arrays II.py) [Java]()|Easy|| +|355|Design Twitter|[Python](python/355 Design Twitter.py) [Java]()|Medium|| +|356|Line Reflection|[Python](python/356 Line Reflection.py) [Java]()|Medium|| +|358|Rearrange String k Distance Apart|[Python](python/358 Rearrange String k Distance Apart.py) [Java]()|Hard|| +|359|Logger Rate Limiter|[Python](python/359 Logger Rate Limiter.py) [Java]()|Easy|| +|380|Insert Delete GetRandom O(1)|[Python](python/380 Insert Delete GetRandom O(1).py) [Java]()|Medium|| +|381|Insert Delete GetRandom O(1) - Duplicates allowed|[Python](python/381 Insert Delete GetRandom O(1) - Duplicates allowed.py) [Java]()|Hard|| +|389|Find the Difference|[Python](python/389 Find the Difference.py) [Java]()|Easy|| +|409|Longest Palindrome|[Python](python/409 Longest Palindrome.py) [Java]()|Easy|| +|438|Find All Anagrams in a String|[Python](python/438 Find All Anagrams in a String.py) [Java]()|Easy|| +|447|Number of Boomerangs|[Python](python/447 Number of Boomerangs.py) [Java]()|Easy|| +|451|Sort Characters By Frequency|[Python](python/451 Sort Characters By Frequency.py) [Java]()|Medium|| +|454|4Sum II|[Python](python/454 4Sum II.py) [Java]()|Medium|| +|463|Island Perimeter|[Python](python/463 Island Perimeter.py) [Java]()|Easy|| +|500|Keyboard Row|[Python](python/500 Keyboard Row.py) [Java]()|Easy|| +|508|Most Frequent Subtree Sum|[Python](python/508 Most Frequent Subtree Sum.py) [Java]()|Medium|| +|525|Contiguous Array|[Python](python/525 Contiguous Array.py) [Java]()|Medium|| +|535|Encode and Decode TinyURL|[Python](python/535 Encode and Decode TinyURL.py) [Java]()|Medium|| +|554|Brick Wall|[Python](python/554 Brick Wall.py) [Java]()|Medium|| + +## Linked List + +| # | Title | Solution | Difficulty | Note | +|-----|---------------- | --------------- | --------------- | --------------- | +|2|Add Two Numbers|[Python](python/002 Add Two Numbers.py) [Java]()|Medium|| +|19|Remove Nth Node From End of List|[Python](python/019 Remove Nth Node From End of List.py) [Java]()|Medium|| +|21|Merge Two Sorted Lists|[Python](python/021 Merge Two Sorted Lists.py) [Java]()|Easy|| +|23|Merge k Sorted Lists|[Python](python/023 Merge k Sorted Lists.py) [Java]()|Hard|| +|24|Swap Nodes in Pairs|[Python](python/024 Swap Nodes in Pairs.py) [Java]()|Medium|| +|25|Reverse Nodes in k-Group|[Python](python/025 Reverse Nodes in k-Group.py) [Java]()|Hard|| +|61|Rotate List|[Python](python/061 Rotate List.py) [Java]()|Medium|| +|82|Remove Duplicates from Sorted List II|[Python](python/082 Remove Duplicates from Sorted List II.py) [Java]()|Medium|| +|83|Remove Duplicates from Sorted List|[Python](python/083 Remove Duplicates from Sorted List.py) [Java]()|Easy|| +|86|Partition List|[Python](python/086 Partition List.py) [Java]()|Medium|| +|92|Reverse Linked List II|[Python](python/092 Reverse Linked List II.py) [Java]()|Medium|| +|109|Convert Sorted List to Binary Search Tree|[Python](python/109 Convert Sorted List to Binary Search Tree.py) [Java]()|Medium|| +|138|Copy List with Random Pointer|[Python](python/138 Copy List with Random Pointer.py) [Java]()|Medium|| +|141|Linked List Cycle|[Python](python/141 Linked List Cycle.py) [Java]()|Easy|| +|142|Linked List Cycle II|[Python](python/142 Linked List Cycle II.py) [Java]()|Medium|| +|143|Reorder List|[Python](python/143 Reorder List.py) [Java]()|Medium|| +|147|Insertion Sort List|[Python](python/147 Insertion Sort List.py) [Java]()|Medium|| +|148|Sort List|[Python](python/148 Sort List.py) [Java]()|Medium|| +|160|Intersection of Two Linked Lists|[Python](python/160 Intersection of Two Linked Lists.py) [Java]()|Easy|| +|203|Remove Linked List Elements|[Python](python/203 Remove Linked List Elements.py) [Java]()|Easy|| +|206|Reverse Linked List|[Python](python/206 Reverse Linked List.py) [Java]()|Easy|| +|234|Palindrome Linked List|[Python](python/234 Palindrome Linked List.py) [Java]()|Easy|| +|237|Delete Node in a Linked List|[Python](python/237 Delete Node in a Linked List.py) [Java]()|Easy|| +|328|Odd Even Linked List|[Python](python/328 Odd Even Linked List.py) [Java]()|Medium|| +|369|Plus One Linked List|[Python](python/369 Plus One Linked List.py) [Java]()|Medium|| +|379|Design Phone Directory|[Python](python/379 Design Phone Directory.py) [Java]()|Medium|| +|445|Add Two Numbers II|[Python](python/445 Add Two Numbers II.py) [Java]()|Medium|| + +## Math + +| # | Title | Solution | Difficulty | Note | +|-----|---------------- | --------------- | --------------- | --------------- | +|2|Add Two Numbers|[Python](python/002 Add Two Numbers.py) [Java]()|Medium|| +|7|Reverse Integer|[Python](python/007 Reverse Integer.py) [Java]()|Easy|| +|8|String to Integer (atoi)|[Python](python/008 String to Integer (atoi).py) [Java]()|Medium|| +|9|Palindrome Number|[Python](python/009 Palindrome Number.py) [Java]()|Easy|| +|12|Integer to Roman|[Python](python/012 Integer to Roman.py) [Java]()|Medium|| +|13|Roman to Integer|[Python](python/013 Roman to Integer.py) [Java]()|Easy|| +|29|Divide Two Integers|[Python](python/029 Divide Two Integers.py) [Java]()|Medium|| +|43|Multiply Strings|[Python](python/043 Multiply Strings.py) [Java]()|Medium|| +|50|Pow(x, n)|[Python](python/050 Pow(x, n).py) [Java]()|Medium|| +|60|Permutation Sequence|[Python](python/060 Permutation Sequence.py) [Java]()|Medium|| +|65|Valid Number|[Python](python/065 Valid Number.py) [Java]()|Hard|| +|66|Plus One|[Python](python/066 Plus One.py) [Java]()|Easy|| +|67|Add Binary|[Python](python/067 Add Binary.py) [Java]()|Easy|| +|69|Sqrt(x)|[Python](python/069 Sqrt(x).py) [Java]()|Easy|| +|149|Max Points on a Line|[Python](python/149 Max Points on a Line.py) [Java]()|Hard|| +|166|Fraction to Recurring Decimal|[Python](python/166 Fraction to Recurring Decimal.py) [Java]()|Medium|| +|168|Excel Sheet Column Title|[Python](python/168 Excel Sheet Column Title.py) [Java]()|Easy|| +|171|Excel Sheet Column Number|[Python](python/171 Excel Sheet Column Number.py) [Java]()|Easy|| +|172|Factorial Trailing Zeroes|[Python](python/172 Factorial Trailing Zeroes.py) [Java]()|Easy|| +|202|Happy Number|[Python](python/202 Happy Number.py) [Java]()|Easy|| +|204|Count Primes|[Python](python/204 Count Primes.py) [Java]()|Easy|| +|223|Rectangle Area|[Python](python/223 Rectangle Area.py) [Java]()|Medium|| +|224|Basic Calculator|[Python](python/224 Basic Calculator.py) [Java]()|Hard|| +|231|Power of Two|[Python](python/231 Power of Two.py) [Java]()|Easy|| +|233|Number of Digit One|[Python](python/233 Number of Digit One.py) [Java]()|Hard|| +|246|Strobogrammatic Number|[Python](python/246 Strobogrammatic Number.py) [Java]()|Easy|| +|247|Strobogrammatic Number II|[Python](python/247 Strobogrammatic Number II.py) [Java]()|Medium|| +|248|Strobogrammatic Number III|[Python](python/248 Strobogrammatic Number III.py) [Java]()|Hard|| +|258|Add Digits|[Python](python/258 Add Digits.py) [Java]()|Easy|| +|263|Ugly Number|[Python](python/263 Ugly Number.py) [Java]()|Easy|| +|264|Ugly Number II|[Python](python/264 Ugly Number II.py) [Java]()|Medium|| +|268|Missing Number|[Python](python/268 Missing Number.py) [Java]()|Easy|| +|273|Integer to English Words|[Python](python/273 Integer to English Words.py) [Java]()|Hard|| +|279|Perfect Squares|[Python](python/279 Perfect Squares.py) [Java]()|Medium|| +|296|Best Meeting Point|[Python](python/296 Best Meeting Point.py) [Java]()|Hard|| +|313|Super Ugly Number|[Python](python/313 Super Ugly Number.py) [Java]()|Medium|| +|319|Bulb Switcher|[Python](python/319 Bulb Switcher.py) [Java]()|Medium|| +|326|Power of Three|[Python](python/326 Power of Three.py) [Java]()|Easy|| +|335|Self Crossing|[Python](python/335 Self Crossing.py) [Java]()|Hard|| +|343|Integer Break|[Python](python/343 Integer Break.py) [Java]()|Medium|| +|356|Line Reflection|[Python](python/356 Line Reflection.py) [Java]()|Medium|| +|357|Count Numbers with Unique Digits|[Python](python/357 Count Numbers with Unique Digits.py) [Java]()|Medium|| +|360|Sort Transformed Array|[Python](python/360 Sort Transformed Array.py) [Java]()|Medium|| +|365|Water and Jug Problem|[Python](python/365 Water and Jug Problem.py) [Java]()|Medium|| +|367|Valid Perfect Square|[Python](python/367 Valid Perfect Square.py) [Java]()|Easy|| +|368|Largest Divisible Subset|[Python](python/368 Largest Divisible Subset.py) [Java]()|Medium|| +|372|Super Pow|[Python](python/372 Super Pow.py) [Java]()|Medium|| +|396|Rotate Function|[Python](python/396 Rotate Function.py) [Java]()|Medium|| +|397|Integer Replacement|[Python](python/397 Integer Replacement.py) [Java]()|Medium|| +|400|Nth Digit|[Python](python/400 Nth Digit.py) [Java]()|Easy|| +|413|Arithmetic Slices|[Python](python/413 Arithmetic Slices.py) [Java]()|Medium|| +|415|Add Strings|[Python](python/415 Add Strings.py) [Java]()|Easy|| +|423|Reconstruct Original Digits from English|[Python](python/423 Reconstruct Original Digits from English.py) [Java]()|Medium|| +|441|Arranging Coins|[Python](python/441 Arranging Coins.py) [Java]()|Easy|| +|453|Minimum Moves to Equal Array Elements|[Python](python/453 Minimum Moves to Equal Array Elements.py) [Java]()|Easy|| +|462|Minimum Moves to Equal Array Elements II|[Python](python/462 Minimum Moves to Equal Array Elements II.py) [Java]()|Medium|| +|469|Convex Polygon|[Python](python/469 Convex Polygon.py) [Java]()|Medium|| +|483|Smallest Good Base|[Python](python/483 Smallest Good Base.py) [Java]()|Hard|| +|507|Perfect Number|[Python](python/507 Perfect Number.py) [Java]()|Easy|| +|517|Super Washing Machines|[Python](python/517 Super Washing Machines.py) [Java]()|Hard|| +|523|Continuous Subarray Sum|[Python](python/523 Continuous Subarray Sum.py) [Java]()|Medium|| +|535|Encode and Decode TinyURL|[Python](python/535 Encode and Decode TinyURL.py) [Java]()|Medium|| +|537|Complex Number Multiplication|[Python](python/537 Complex Number Multiplication.py) [Java]()|Medium|| +|553|Optimal Division|[Python](python/553 Optimal Division.py) [Java]()|Medium|| + +## Two Pointers + +| # | Title | Solution | Difficulty | Note | +|-----|---------------- | --------------- | --------------- | --------------- | +|3|Longest Substring Without Repeating Characters|[Python](python/003 Longest Substring Without Repeating Characters.py) [Java]()|Medium|| +|11|Container With Most Water|[Python](python/011 Container With Most Water.py) [Java]()|Medium|| +|15|3Sum|[Python](python/015 3Sum.py) [Java]()|Medium|| +|16|3Sum Closest|[Python](python/016 3Sum Closest.py) [Java]()|Medium|| +|18|4Sum|[Python](python/018 4Sum.py) [Java]()|Medium|| +|19|Remove Nth Node From End of List|[Python](python/019 Remove Nth Node From End of List.py) [Java]()|Medium|| +|26|Remove Duplicates from Sorted Array|[Python](python/026 Remove Duplicates from Sorted Array.py) [Java]()|Easy|| +|27|Remove Element|[Python](python/027 Remove Element.py) [Java]()|Easy|| +|28|Implement strStr()|[Python](python/028 Implement strStr().py) [Java]()|Easy|| +|30|Substring with Concatenation of All Words|[Python](python/030 Substring with Concatenation of All Words.py) [Java]()|Hard|| +|42|Trapping Rain Water|[Python](python/042 Trapping Rain Water.py) [Java]()|Hard|| +|61|Rotate List|[Python](python/061 Rotate List.py) [Java]()|Medium|| +|75|Sort Colors|[Python](python/075 Sort Colors.py) [Java]()|Medium|| +|76|Minimum Window Substring|[Python](python/076 Minimum Window Substring.py) [Java]()|Hard|| +|80|Remove Duplicates from Sorted Array II|[Python](python/080 Remove Duplicates from Sorted Array II.py) [Java]()|Medium|| +|86|Partition List|[Python](python/086 Partition List.py) [Java]()|Medium|| +|88|Merge Sorted Array|[Python](python/088 Merge Sorted Array.py) [Java]()|Easy|| +|125|Valid Palindrome|[Python](python/125 Valid Palindrome.py) [Java]()|Easy|| +|141|Linked List Cycle|[Python](python/141 Linked List Cycle.py) [Java]()|Easy|| +|142|Linked List Cycle II|[Python](python/142 Linked List Cycle II.py) [Java]()|Medium|| +|159|Longest Substring with At Most Two Distinct Characters|[Python](python/159 Longest Substring with At Most Two Distinct Characters.py) [Java]()|Hard|| +|167|Two Sum II - Input array is sorted|[Python](python/167 Two Sum II - Input array is sorted.py) [Java]()|Easy|| +|209|Minimum Size Subarray Sum|[Python](python/209 Minimum Size Subarray Sum.py) [Java]()|Medium|| +|234|Palindrome Linked List|[Python](python/234 Palindrome Linked List.py) [Java]()|Easy|| +|259|3Sum Smaller|[Python](python/259 3Sum Smaller.py) [Java]()|Medium|| +|283|Move Zeroes|[Python](python/283 Move Zeroes.py) [Java]()|Easy|| +|287|Find the Duplicate Number|[Python](python/287 Find the Duplicate Number.py) [Java]()|Medium|| +|344|Reverse String|[Python](python/344 Reverse String.py) [Java]()|Easy|| +|345|Reverse Vowels of a String|[Python](python/345 Reverse Vowels of a String.py) [Java]()|Easy|| +|349|Intersection of Two Arrays|[Python](python/349 Intersection of Two Arrays.py) [Java]()|Easy|| +|350|Intersection of Two Arrays II|[Python](python/350 Intersection of Two Arrays II.py) [Java]()|Easy|| +|360|Sort Transformed Array|[Python](python/360 Sort Transformed Array.py) [Java]()|Medium|| +|487|Max Consecutive Ones II|[Python](python/487 Max Consecutive Ones II.py) [Java]()|Medium|| +|524|Longest Word in Dictionary through Deleting|[Python](python/524 Longest Word in Dictionary through Deleting.py) [Java]()|Medium|| +|532|K-diff Pairs in an Array|[Python](python/532 K-diff Pairs in an Array.py) [Java]()|Easy|| +|567|Permutation in String|[Python](python/567 Permutation in String.py) [Java]()|Medium|| + +## String + +| # | Title | Solution | Difficulty | Note | +|-----|---------------- | --------------- | --------------- | --------------- | +|3|Longest Substring Without Repeating Characters|[Python](python/003 Longest Substring Without Repeating Characters.py) [Java]()|Medium|| +|5|Longest Palindromic Substring|[Python](python/005 Longest Palindromic Substring.py) [Java]()|Medium|| +|6|ZigZag Conversion|[Python](python/006 ZigZag Conversion.py) [Java]()|Medium|| +|8|String to Integer (atoi)|[Python](python/008 String to Integer (atoi).py) [Java]()|Medium|| +|10|Regular Expression Matching|[Python](python/010 Regular Expression Matching.py) [Java]()|Hard|| +|12|Integer to Roman|[Python](python/012 Integer to Roman.py) [Java]()|Medium|| +|13|Roman to Integer|[Python](python/013 Roman to Integer.py) [Java]()|Easy|| +|14|Longest Common Prefix|[Python](python/014 Longest Common Prefix.py) [Java]()|Easy|| +|17|Letter Combinations of a Phone Number|[Python](python/017 Letter Combinations of a Phone Number.py) [Java]()|Medium|| +|20|Valid Parentheses|[Python](python/020 Valid Parentheses.py) [Java]()|Easy|| +|22|Generate Parentheses|[Python](python/022 Generate Parentheses.py) [Java]()|Medium|| +|28|Implement strStr()|[Python](python/028 Implement strStr().py) [Java]()|Easy|| +|30|Substring with Concatenation of All Words|[Python](python/030 Substring with Concatenation of All Words.py) [Java]()|Hard|| +|32|Longest Valid Parentheses|[Python](python/032 Longest Valid Parentheses.py) [Java]()|Hard|| +|38|Count and Say|[Python](python/038 Count and Say.py) [Java]()|Easy|| +|43|Multiply Strings|[Python](python/043 Multiply Strings.py) [Java]()|Medium|| +|44|Wildcard Matching|[Python](python/044 Wildcard Matching.py) [Java]()|Hard|| +|49|Group Anagrams|[Python](python/049 Group Anagrams.py) [Java]()|Medium|| +|58|Length of Last Word|[Python](python/058 Length of Last Word.py) [Java]()|Easy|| +|65|Valid Number|[Python](python/065 Valid Number.py) [Java]()|Hard|| +|67|Add Binary|[Python](python/067 Add Binary.py) [Java]()|Easy|| +|68|Text Justification|[Python](python/068 Text Justification.py) [Java]()|Hard|| +|71|Simplify Path|[Python](python/071 Simplify Path.py) [Java]()|Medium|| +|72|Edit Distance|[Python](python/072 Edit Distance.py) [Java]()|Hard|| +|76|Minimum Window Substring|[Python](python/076 Minimum Window Substring.py) [Java]()|Hard|| +|87|Scramble String|[Python](python/087 Scramble String.py) [Java]()|Hard|| +|91|Decode Ways|[Python](python/091 Decode Ways.py) [Java]()|Medium|| +|93|Restore IP Addresses|[Python](python/093 Restore IP Addresses.py) [Java]()|Medium|| +|97|Interleaving String|[Python](python/097 Interleaving String.py) [Java]()|Hard|| +|115|Distinct Subsequences|[Python](python/115 Distinct Subsequences.py) [Java]()|Hard|| +|125|Valid Palindrome|[Python](python/125 Valid Palindrome.py) [Java]()|Easy|| +|126|Word Ladder II|[Python](python/126 Word Ladder II.py) [Java]()|Hard|| +|151|Reverse Words in a String|[Python](python/151 Reverse Words in a String.py) [Java]()|Medium|| +|157|Read N Characters Given Read4|[Python](python/157 Read N Characters Given Read4.py) [Java]()|Easy|| +|158|Read N Characters Given Read4 II - Call multiple times|[Python](python/158 Read N Characters Given Read4 II - Call multiple times.py) [Java]()|Hard|| +|159|Longest Substring with At Most Two Distinct Characters|[Python](python/159 Longest Substring with At Most Two Distinct Characters.py) [Java]()|Hard|| +|161|One Edit Distance|[Python](python/161 One Edit Distance.py) [Java]()|Medium|| +|165|Compare Version Numbers|[Python](python/165 Compare Version Numbers.py) [Java]()|Medium|| +|186|Reverse Words in a String II|[Python](python/186 Reverse Words in a String II.py) [Java]()|Medium|| +|214|Shortest Palindrome|[Python](python/214 Shortest Palindrome.py) [Java]()|Hard|| +|227|Basic Calculator II|[Python](python/227 Basic Calculator II.py) [Java]()|Medium|| +|249|Group Shifted Strings|[Python](python/249 Group Shifted Strings.py) [Java]()|Medium|| +|271|Encode and Decode Strings|[Python](python/271 Encode and Decode Strings.py) [Java]()|Medium|| +|273|Integer to English Words|[Python](python/273 Integer to English Words.py) [Java]()|Hard|| +|293|Flip Game|[Python](python/293 Flip Game.py) [Java]()|Easy|| +|336|Palindrome Pairs|[Python](python/336 Palindrome Pairs.py) [Java]()|Hard|| +|340|Longest Substring with At Most K Distinct Characters|[Python](python/340 Longest Substring with At Most K Distinct Characters.py) [Java]()|Hard|| +|344|Reverse String|[Python](python/344 Reverse String.py) [Java]()|Easy|| +|345|Reverse Vowels of a String|[Python](python/345 Reverse Vowels of a String.py) [Java]()|Easy|| +|383|Ransom Note|[Python](python/383 Ransom Note.py) [Java]()|Easy|| +|385|Mini Parser|[Python](python/385 Mini Parser.py) [Java]()|Medium|| +|408|Valid Word Abbreviation|[Python](python/408 Valid Word Abbreviation.py) [Java]()|Easy|| +|434|Number of Segments in a String|[Python](python/434 Number of Segments in a String.py) [Java]()|Easy|| +|459|Repeated Substring Pattern|[Python](python/459 Repeated Substring Pattern.py) [Java]()|Easy|| +|468|Validate IP Address|[Python](python/468 Validate IP Address.py) [Java]()|Medium|| +|520|Detect Capital|[Python](python/520 Detect Capital.py) [Java]()|Easy|| +|521|Longest Uncommon Subsequence I|[Python](python/521 Longest Uncommon Subsequence I.py) [Java]()|Easy|| +|522|Longest Uncommon Subsequence II|[Python](python/522 Longest Uncommon Subsequence II.py) [Java]()|Medium|| +|527|Word Abbreviation|[Python](python/527 Word Abbreviation.py) [Java]()|Hard|| +|536|Construct Binary Tree from String|[Python](python/536 Construct Binary Tree from String.py) [Java]()|Medium|| +|537|Complex Number Multiplication|[Python](python/537 Complex Number Multiplication.py) [Java]()|Medium|| +|539|Minimum Time Difference|[Python](python/539 Minimum Time Difference.py) [Java]()|Medium|| +|541|Reverse String II|[Python](python/541 Reverse String II.py) [Java]()|Easy|| +|544|Output Contest Matches|[Python](python/544 Output Contest Matches.py) [Java]()|Medium|| +|551|Student Attendance Record I|[Python](python/551 Student Attendance Record I.py) [Java]()|Easy|| +|553|Optimal Division|[Python](python/553 Optimal Division.py) [Java]()|Medium|| +|555|Split Concatenated Strings|[Python](python/555 Split Concatenated Strings.py) [Java]()|Medium|| +|556|Next Greater Element III|[Python](python/556 Next Greater Element III.py) [Java]()|Medium|| +|557|Reverse Words in a String III|[Python](python/557 Reverse Words in a String III.py) [Java]()|Easy|| +|564|Find the Closest Palindrome|[Python](python/564 Find the Closest Palindrome.py) [Java]()|Hard|| + +## Binary Search + +| # | Title | Solution | Difficulty | Note | +|-----|---------------- | --------------- | --------------- | --------------- | +|4|Median of Two Sorted Arrays|[Python](python/004 Median of Two Sorted Arrays.py) [Java]()|Hard|| +|29|Divide Two Integers|[Python](python/029 Divide Two Integers.py) [Java]()|Medium|| +|33|Search in Rotated Sorted Array|[Python](python/033 Search in Rotated Sorted Array.py) [Java]()|Medium|| +|34|Search for a Range|[Python](python/034 Search for a Range.py) [Java]()|Medium|| +|35|Search Insert Position|[Python](python/035 Search Insert Position.py) [Java]()|Easy|| +|50|Pow(x, n)|[Python](python/050 Pow(x, n).py) [Java]()|Medium|| +|69|Sqrt(x)|[Python](python/069 Sqrt(x).py) [Java]()|Easy|| +|74|Search a 2D Matrix|[Python](python/074 Search a 2D Matrix.py) [Java]()|Medium|| +|81|Search in Rotated Sorted Array II|[Python](python/081 Search in Rotated Sorted Array II.py) [Java]()|Medium|| +|153|Find Minimum in Rotated Sorted Array|[Python](python/153 Find Minimum in Rotated Sorted Array.py) [Java]()|Medium|| +|154|Find Minimum in Rotated Sorted Array II|[Python](python/154 Find Minimum in Rotated Sorted Array II.py) [Java]()|Hard|| +|162|Find Peak Element|[Python](python/162 Find Peak Element.py) [Java]()|Medium|| +|167|Two Sum II - Input array is sorted|[Python](python/167 Two Sum II - Input array is sorted.py) [Java]()|Easy|| +|174|Dungeon Game|[Python](python/174 Dungeon Game.py) [Java]()|Hard|| +|209|Minimum Size Subarray Sum|[Python](python/209 Minimum Size Subarray Sum.py) [Java]()|Medium|| +|222|Count Complete Tree Nodes|[Python](python/222 Count Complete Tree Nodes.py) [Java]()|Medium|| +|230|Kth Smallest Element in a BST|[Python](python/230 Kth Smallest Element in a BST.py) [Java]()|Medium|| +|240|Search a 2D Matrix II|[Python](python/240 Search a 2D Matrix II.py) [Java]()|Medium|| +|270|Closest Binary Search Tree Value|[Python](python/270 Closest Binary Search Tree Value.py) [Java]()|Easy|| +|275|H-Index II|[Python](python/275 H-Index II.py) [Java]()|Medium|| +|278|First Bad Version|[Python](python/278 First Bad Version.py) [Java]()|Easy|| +|287|Find the Duplicate Number|[Python](python/287 Find the Duplicate Number.py) [Java]()|Medium|| +|300|Longest Increasing Subsequence|[Python](python/300 Longest Increasing Subsequence.py) [Java]()|Medium|| +|302|Smallest Rectangle Enclosing Black Pixels|[Python](python/302 Smallest Rectangle Enclosing Black Pixels.py) [Java]()|Hard|| +|349|Intersection of Two Arrays|[Python](python/349 Intersection of Two Arrays.py) [Java]()|Easy|| +|350|Intersection of Two Arrays II|[Python](python/350 Intersection of Two Arrays II.py) [Java]()|Easy|| +|354|Russian Doll Envelopes|[Python](python/354 Russian Doll Envelopes.py) [Java]()|Hard|| +|363|Max Sum of Rectangle No Larger Than K|[Python](python/363 Max Sum of Rectangle No Larger Than K.py) [Java]()|Hard|| +|367|Valid Perfect Square|[Python](python/367 Valid Perfect Square.py) [Java]()|Easy|| +|374|Guess Number Higher or Lower|[Python](python/374 Guess Number Higher or Lower.py) [Java]()|Easy|| +|378|Kth Smallest Element in a Sorted Matrix|[Python](python/378 Kth Smallest Element in a Sorted Matrix.py) [Java]()|Medium|| +|392|Is Subsequence|[Python](python/392 Is Subsequence.py) [Java]()|Medium|| +|410|Split Array Largest Sum|[Python](python/410 Split Array Largest Sum.py) [Java]()|Hard|| +|436|Find Right Interval|[Python](python/436 Find Right Interval.py) [Java]()|Medium|| +|441|Arranging Coins|[Python](python/441 Arranging Coins.py) [Java]()|Easy|| +|454|4Sum II|[Python](python/454 4Sum II.py) [Java]()|Medium|| +|475|Heaters|[Python](python/475 Heaters.py) [Java]()|Easy|| +|483|Smallest Good Base|[Python](python/483 Smallest Good Base.py) [Java]()|Hard|| + +## Divide and Conquer + +| # | Title | Solution | Difficulty | Note | +|-----|---------------- | --------------- | --------------- | --------------- | +|4|Median of Two Sorted Arrays|[Python](python/004 Median of Two Sorted Arrays.py) [Java]()|Hard|| +|23|Merge k Sorted Lists|[Python](python/023 Merge k Sorted Lists.py) [Java]()|Hard|| +|53|Maximum Subarray|[Python](python/053 Maximum Subarray.py) [Java]()|Easy|| +|169|Majority Element|[Python](python/169 Majority Element.py) [Java]()|Easy|| +|215|Kth Largest Element in an Array|[Python](python/215 Kth Largest Element in an Array.py) [Java]()|Medium|| +|218|The Skyline Problem|[Python](python/218 The Skyline Problem.py) [Java]()|Hard|| +|240|Search a 2D Matrix II|[Python](python/240 Search a 2D Matrix II.py) [Java]()|Medium|| +|241|Different Ways to Add Parentheses|[Python](python/241 Different Ways to Add Parentheses.py) [Java]()|Medium|| +|282|Expression Add Operators|[Python](python/282 Expression Add Operators.py) [Java]()|Hard|| +|312|Burst Balloons|[Python](python/312 Burst Balloons.py) [Java]()|Hard|| +|315|Count of Smaller Numbers After Self|[Python](python/315 Count of Smaller Numbers After Self.py) [Java]()|Hard|| +|327|Count of Range Sum|[Python](python/327 Count of Range Sum.py) [Java]()|Hard|| +|493|Reverse Pairs|[Python](python/493 Reverse Pairs.py) [Java]()|Hard|| +|514|Freedom Trail|[Python](python/514 Freedom Trail.py) [Java]()|Hard|| + +## Dynamic Programming + +| # | Title | Solution | Difficulty | Note | +|-----|---------------- | --------------- | --------------- | --------------- | +|10|Regular Expression Matching|[Python](python/010 Regular Expression Matching.py) [Java]()|Hard|| +|32|Longest Valid Parentheses|[Python](python/032 Longest Valid Parentheses.py) [Java]()|Hard|| +|44|Wildcard Matching|[Python](python/044 Wildcard Matching.py) [Java]()|Hard|| +|53|Maximum Subarray|[Python](python/053 Maximum Subarray.py) [Java]()|Easy|| +|62|Unique Paths|[Python](python/062 Unique Paths.py) [Java]()|Medium|| +|63|Unique Paths II|[Python](python/063 Unique Paths II.py) [Java]()|Medium|| +|64|Minimum Path Sum|[Python](python/064 Minimum Path Sum.py) [Java]()|Medium|| +|70|Climbing Stairs|[Python](python/070 Climbing Stairs.py) [Java]()|Easy|| +|72|Edit Distance|[Python](python/072 Edit Distance.py) [Java]()|Hard|| +|85|Maximal Rectangle|[Python](python/085 Maximal Rectangle.py) [Java]()|Hard|| +|87|Scramble String|[Python](python/087 Scramble String.py) [Java]()|Hard|| +|91|Decode Ways|[Python](python/091 Decode Ways.py) [Java]()|Medium|| +|95|Unique Binary Search Trees II|[Python](python/095 Unique Binary Search Trees II.py) [Java]()|Medium|| +|96|Unique Binary Search Trees|[Python](python/096 Unique Binary Search Trees.py) [Java]()|Medium|| +|97|Interleaving String|[Python](python/097 Interleaving String.py) [Java]()|Hard|| +|115|Distinct Subsequences|[Python](python/115 Distinct Subsequences.py) [Java]()|Hard|| +|120|Triangle|[Python](python/120 Triangle.py) [Java]()|Medium|| +|121|Best Time to Buy and Sell Stock|[Python](python/121 Best Time to Buy and Sell Stock.py) [Java]()|Easy|| +|123|Best Time to Buy and Sell Stock III|[Python](python/123 Best Time to Buy and Sell Stock III.py) [Java]()|Hard|| +|132|Palindrome Partitioning II|[Python](python/132 Palindrome Partitioning II.py) [Java]()|Hard|| +|139|Word Break|[Python](python/139 Word Break.py) [Java]()|Medium|| +|140|Word Break II|[Python](python/140 Word Break II.py) [Java]()|Hard|| +|152|Maximum Product Subarray|[Python](python/152 Maximum Product Subarray.py) [Java]()|Medium|| +|174|Dungeon Game|[Python](python/174 Dungeon Game.py) [Java]()|Hard|| +|188|Best Time to Buy and Sell Stock IV|[Python](python/188 Best Time to Buy and Sell Stock IV.py) [Java]()|Hard|| +|198|House Robber|[Python](python/198 House Robber.py) [Java]()|Easy|| +|213|House Robber II|[Python](python/213 House Robber II.py) [Java]()|Medium|| +|221|Maximal Square|[Python](python/221 Maximal Square.py) [Java]()|Medium|| +|256|Paint House|[Python](python/256 Paint House.py) [Java]()|Easy|| +|264|Ugly Number II|[Python](python/264 Ugly Number II.py) [Java]()|Medium|| +|265|Paint House II|[Python](python/265 Paint House II.py) [Java]()|Hard|| +|276|Paint Fence|[Python](python/276 Paint Fence.py) [Java]()|Easy|| +|279|Perfect Squares|[Python](python/279 Perfect Squares.py) [Java]()|Medium|| +|300|Longest Increasing Subsequence|[Python](python/300 Longest Increasing Subsequence.py) [Java]()|Medium|| +|303|Range Sum Query - Immutable|[Python](python/303 Range Sum Query - Immutable.py) [Java]()|Easy|| +|304|Range Sum Query 2D - Immutable|[Python](python/304 Range Sum Query 2D - Immutable.py) [Java]()|Medium|| +|309|Best Time to Buy and Sell Stock with Cooldown|[Python](python/309 Best Time to Buy and Sell Stock with Cooldown.py) [Java]()|Medium|| +|312|Burst Balloons|[Python](python/312 Burst Balloons.py) [Java]()|Hard|| +|321|Create Maximum Number|[Python](python/321 Create Maximum Number.py) [Java]()|Hard|| +|322|Coin Change|[Python](python/322 Coin Change.py) [Java]()|Medium|| +|338|Counting Bits|[Python](python/338 Counting Bits.py) [Java]()|Medium|| +|343|Integer Break|[Python](python/343 Integer Break.py) [Java]()|Medium|| +|351|Android Unlock Patterns|[Python](python/351 Android Unlock Patterns.py) [Java]()|Medium|| +|354|Russian Doll Envelopes|[Python](python/354 Russian Doll Envelopes.py) [Java]()|Hard|| +|357|Count Numbers with Unique Digits|[Python](python/357 Count Numbers with Unique Digits.py) [Java]()|Medium|| +|361|Bomb Enemy|[Python](python/361 Bomb Enemy.py) [Java]()|Medium|| +|363|Max Sum of Rectangle No Larger Than K|[Python](python/363 Max Sum of Rectangle No Larger Than K.py) [Java]()|Hard|| +|368|Largest Divisible Subset|[Python](python/368 Largest Divisible Subset.py) [Java]()|Medium|| +|375|Guess Number Higher or Lower II|[Python](python/375 Guess Number Higher or Lower II.py) [Java]()|Medium|| +|376|Wiggle Subsequence|[Python](python/376 Wiggle Subsequence.py) [Java]()|Medium|| +|377|Combination Sum IV|[Python](python/377 Combination Sum IV.py) [Java]()|Medium|| +|392|Is Subsequence|[Python](python/392 Is Subsequence.py) [Java]()|Medium|| +|403|Frog Jump|[Python](python/403 Frog Jump.py) [Java]()|Hard|| +|410|Split Array Largest Sum|[Python](python/410 Split Array Largest Sum.py) [Java]()|Hard|| +|413|Arithmetic Slices|[Python](python/413 Arithmetic Slices.py) [Java]()|Medium|| +|416|Partition Equal Subset Sum|[Python](python/416 Partition Equal Subset Sum.py) [Java]()|Medium|| +|418|Sentence Screen Fitting|[Python](python/418 Sentence Screen Fitting.py) [Java]()|Medium|| +|446|Arithmetic Slices II - Subsequence|[Python](python/446 Arithmetic Slices II - Subsequence.py) [Java]()|Hard|| +|464|Can I Win|[Python](python/464 Can I Win.py) [Java]()|Medium|| +|466|Count The Repetitions|[Python](python/466 Count The Repetitions.py) [Java]()|Hard|| +|467|Unique Substrings in Wraparound String|[Python](python/467 Unique Substrings in Wraparound String.py) [Java]()|Medium|| +|471|Encode String with Shortest Length|[Python](python/471 Encode String with Shortest Length.py) [Java]()|Hard|| +|472|Concatenated Words|[Python](python/472 Concatenated Words.py) [Java]()|Hard|| +|474|Ones and Zeroes|[Python](python/474 Ones and Zeroes.py) [Java]()|Medium|| +|486|Predict the Winner|[Python](python/486 Predict the Winner.py) [Java]()|Medium|| +|494|Target Sum|[Python](python/494 Target Sum.py) [Java]()|Medium|| +|514|Freedom Trail|[Python](python/514 Freedom Trail.py) [Java]()|Hard|| +|516|Longest Palindromic Subsequence|[Python](python/516 Longest Palindromic Subsequence.py) [Java]()|Medium|| +|517|Super Washing Machines|[Python](python/517 Super Washing Machines.py) [Java]()|Hard|| +|523|Continuous Subarray Sum|[Python](python/523 Continuous Subarray Sum.py) [Java]()|Medium|| +|546|Remove Boxes|[Python](python/546 Remove Boxes.py) [Java]()|Hard|| +|552|Student Attendance Record II|[Python](python/552 Student Attendance Record II.py) [Java]()|Hard|| +|568|Maximum Vacation Days|[Python](python/568 Maximum Vacation Days.py) [Java]()|Hard|| + +## Backtracking + +| # | Title | Solution | Difficulty | Note | +|-----|---------------- | --------------- | --------------- | --------------- | +|10|Regular Expression Matching|[Python](python/010 Regular Expression Matching.py) [Java]()|Hard|| +|17|Letter Combinations of a Phone Number|[Python](python/017 Letter Combinations of a Phone Number.py) [Java]()|Medium|| +|22|Generate Parentheses|[Python](python/022 Generate Parentheses.py) [Java]()|Medium|| +|37|Sudoku Solver|[Python](python/037 Sudoku Solver.py) [Java]()|Hard|| +|39|Combination Sum|[Python](python/039 Combination Sum.py) [Java]()|Medium|| +|40|Combination Sum II|[Python](python/040 Combination Sum II.py) [Java]()|Medium|| +|44|Wildcard Matching|[Python](python/044 Wildcard Matching.py) [Java]()|Hard|| +|46|Permutations|[Python](python/046 Permutations.py) [Java]()|Medium|| +|47|Permutations II|[Python](python/047 Permutations II.py) [Java]()|Medium|| +|51|N-Queens|[Python](python/051 N-Queens.py) [Java]()|Hard|| +|52|N-Queens II|[Python](python/052 N-Queens II.py) [Java]()|Hard|| +|60|Permutation Sequence|[Python](python/060 Permutation Sequence.py) [Java]()|Medium|| +|77|Combinations|[Python](python/077 Combinations.py) [Java]()|Medium|| +|78|Subsets|[Python](python/078 Subsets.py) [Java]()|Medium|| +|79|Word Search|[Python](python/079 Word Search.py) [Java]()|Medium|| +|89|Gray Code|[Python](python/089 Gray Code.py) [Java]()|Medium|| +|90|Subsets II|[Python](python/090 Subsets II.py) [Java]()|Medium|| +|93|Restore IP Addresses|[Python](python/093 Restore IP Addresses.py) [Java]()|Medium|| +|126|Word Ladder II|[Python](python/126 Word Ladder II.py) [Java]()|Hard|| +|131|Palindrome Partitioning|[Python](python/131 Palindrome Partitioning.py) [Java]()|Medium|| +|140|Word Break II|[Python](python/140 Word Break II.py) [Java]()|Hard|| +|211|Add and Search Word - Data structure design|[Python](python/211 Add and Search Word - Data structure design.py) [Java]()|Medium|| +|212|Word Search II|[Python](python/212 Word Search II.py) [Java]()|Hard|| +|216|Combination Sum III|[Python](python/216 Combination Sum III.py) [Java]()|Medium|| +|254|Factor Combinations|[Python](python/254 Factor Combinations.py) [Java]()|Medium|| +|267|Palindrome Permutation II|[Python](python/267 Palindrome Permutation II.py) [Java]()|Medium|| +|291|Word Pattern II|[Python](python/291 Word Pattern II.py) [Java]()|Hard|| +|294|Flip Game II|[Python](python/294 Flip Game II.py) [Java]()|Medium|| +|320|Generalized Abbreviation|[Python](python/320 Generalized Abbreviation.py) [Java]()|Medium|| +|351|Android Unlock Patterns|[Python](python/351 Android Unlock Patterns.py) [Java]()|Medium|| +|357|Count Numbers with Unique Digits|[Python](python/357 Count Numbers with Unique Digits.py) [Java]()|Medium|| +|401|Binary Watch|[Python](python/401 Binary Watch.py) [Java]()|Easy|| +|411|Minimum Unique Word Abbreviation|[Python](python/411 Minimum Unique Word Abbreviation.py) [Java]()|Hard|| +|425|Word Squares|[Python](python/425 Word Squares.py) [Java]()|Hard|| +|526|Beautiful Arrangement|[Python](python/526 Beautiful Arrangement.py) [Java]()|Medium|| + +## Stack + +| # | Title | Solution | Difficulty | Note | +|-----|---------------- | --------------- | --------------- | --------------- | +|20|Valid Parentheses|[Python](python/020 Valid Parentheses.py) [Java]()|Easy|| +|42|Trapping Rain Water|[Python](python/042 Trapping Rain Water.py) [Java]()|Hard|| +|71|Simplify Path|[Python](python/071 Simplify Path.py) [Java]()|Medium|| +|84|Largest Rectangle in Histogram|[Python](python/084 Largest Rectangle in Histogram.py) [Java]()|Hard|| +|85|Maximal Rectangle|[Python](python/085 Maximal Rectangle.py) [Java]()|Hard|| +|94|Binary Tree Inorder Traversal|[Python](python/094 Binary Tree Inorder Traversal.py) [Java]()|Medium|| +|103|Binary Tree Zigzag Level Order Traversal|[Python](python/103 Binary Tree Zigzag Level Order Traversal.py) [Java]()|Medium|| +|144|Binary Tree Preorder Traversal|[Python](python/144 Binary Tree Preorder Traversal.py) [Java]()|Medium|| +|145|Binary Tree Postorder Traversal|[Python](python/145 Binary Tree Postorder Traversal.py) [Java]()|Hard|| +|150|Evaluate Reverse Polish Notation|[Python](python/150 Evaluate Reverse Polish Notation.py) [Java]()|Medium|| +|155|Min Stack|[Python](python/155 Min Stack.py) [Java]()|Easy|| +|173|Binary Search Tree Iterator|[Python](python/173 Binary Search Tree Iterator.py) [Java]()|Medium|| +|224|Basic Calculator|[Python](python/224 Basic Calculator.py) [Java]()|Hard|| +|225|Implement Stack using Queues|[Python](python/225 Implement Stack using Queues.py) [Java]()|Easy|| +|232|Implement Queue using Stacks|[Python](python/232 Implement Queue using Stacks.py) [Java]()|Easy|| +|255|Verify Preorder Sequence in Binary Search Tree|[Python](python/255 Verify Preorder Sequence in Binary Search Tree.py) [Java]()|Medium|| +|272|Closest Binary Search Tree Value II|[Python](python/272 Closest Binary Search Tree Value II.py) [Java]()|Hard|| +|316|Remove Duplicate Letters|[Python](python/316 Remove Duplicate Letters.py) [Java]()|Hard|| +|331|Verify Preorder Serialization of a Binary Tree|[Python](python/331 Verify Preorder Serialization of a Binary Tree.py) [Java]()|Medium|| +|341|Flatten Nested List Iterator|[Python](python/341 Flatten Nested List Iterator.py) [Java]()|Medium|| +|385|Mini Parser|[Python](python/385 Mini Parser.py) [Java]()|Medium|| +|394|Decode String|[Python](python/394 Decode String.py) [Java]()|Medium|| +|402|Remove K Digits|[Python](python/402 Remove K Digits.py) [Java]()|Medium|| +|439|Ternary Expression Parser|[Python](python/439 Ternary Expression Parser.py) [Java]()|Medium|| +|456|132 Pattern|[Python](python/456 132 Pattern.py) [Java]()|Medium|| +|496|Next Greater Element I|[Python](python/496 Next Greater Element I.py) [Java]()|Easy|| +|503|Next Greater Element II|[Python](python/503 Next Greater Element II.py) [Java]()|Medium|| + +## Heap + +| # | Title | Solution | Difficulty | Note | +|-----|---------------- | --------------- | --------------- | --------------- | +|23|Merge k Sorted Lists|[Python](python/023 Merge k Sorted Lists.py) [Java]()|Hard|| +|215|Kth Largest Element in an Array|[Python](python/215 Kth Largest Element in an Array.py) [Java]()|Medium|| +|218|The Skyline Problem|[Python](python/218 The Skyline Problem.py) [Java]()|Hard|| +|239|Sliding Window Maximum|[Python](python/239 Sliding Window Maximum.py) [Java]()|Hard|| +|253|Meeting Rooms II|[Python](python/253 Meeting Rooms II.py) [Java]()|Medium|| +|264|Ugly Number II|[Python](python/264 Ugly Number II.py) [Java]()|Medium|| +|295|Find Median from Data Stream|[Python](python/295 Find Median from Data Stream.py) [Java]()|Hard|| +|313|Super Ugly Number|[Python](python/313 Super Ugly Number.py) [Java]()|Medium|| +|347|Top K Frequent Elements|[Python](python/347 Top K Frequent Elements.py) [Java]()|Medium|| +|355|Design Twitter|[Python](python/355 Design Twitter.py) [Java]()|Medium|| +|358|Rearrange String k Distance Apart|[Python](python/358 Rearrange String k Distance Apart.py) [Java]()|Hard|| +|373|Find K Pairs with Smallest Sums|[Python](python/373 Find K Pairs with Smallest Sums.py) [Java]()|Medium|| +|378|Kth Smallest Element in a Sorted Matrix|[Python](python/378 Kth Smallest Element in a Sorted Matrix.py) [Java]()|Medium|| +|407|Trapping Rain Water II|[Python](python/407 Trapping Rain Water II.py) [Java]()|Hard|| +|451|Sort Characters By Frequency|[Python](python/451 Sort Characters By Frequency.py) [Java]()|Medium|| +|502|IPO|[Python](python/502 IPO.py) [Java]()|Hard|| + +## Tree + +| # | Title | Solution | Difficulty | Note | +|-----|---------------- | --------------- | --------------- | --------------- | +|94|Binary Tree Inorder Traversal|[Python](python/094 Binary Tree Inorder Traversal.py) [Java]()|Medium|| +|95|Unique Binary Search Trees II|[Python](python/095 Unique Binary Search Trees II.py) [Java]()|Medium|| +|96|Unique Binary Search Trees|[Python](python/096 Unique Binary Search Trees.py) [Java]()|Medium|| +|98|Validate Binary Search Tree|[Python](python/098 Validate Binary Search Tree.py) [Java]()|Medium|| +|99|Recover Binary Search Tree|[Python](python/099 Recover Binary Search Tree.py) [Java]()|Hard|| +|100|Same Tree|[Python](python/100 Same Tree.py) [Java]()|Easy|| +|101|Symmetric Tree|[Python](python/101 Symmetric Tree.py) [Java]()|Easy|| +|102|Binary Tree Level Order Traversal|[Python](python/102 Binary Tree Level Order Traversal.py) [Java]()|Medium|| +|103|Binary Tree Zigzag Level Order Traversal|[Python](python/103 Binary Tree Zigzag Level Order Traversal.py) [Java]()|Medium|| +|104|Maximum Depth of Binary Tree|[Python](python/104 Maximum Depth of Binary Tree.py) [Java]()|Easy|| +|105|Construct Binary Tree from Preorder and Inorder Traversal|[Python](python/105 Construct Binary Tree from Preorder and Inorder Traversal.py) [Java]()|Medium|| +|106|Construct Binary Tree from Inorder and Postorder Traversal|[Python](python/106 Construct Binary Tree from Inorder and Postorder Traversal.py) [Java]()|Medium|| +|107|Binary Tree Level Order Traversal II|[Python](python/107 Binary Tree Level Order Traversal II.py) [Java]()|Easy|| +|108|Convert Sorted Array to Binary Search Tree|[Python](python/108 Convert Sorted Array to Binary Search Tree.py) [Java]()|Easy|| +|110|Balanced Binary Tree|[Python](python/110 Balanced Binary Tree.py) [Java]()|Easy|| +|111|Minimum Depth of Binary Tree|[Python](python/111 Minimum Depth of Binary Tree.py) [Java]()|Easy|| +|112|Path Sum|[Python](python/112 Path Sum.py) [Java]()|Easy|| +|113|Path Sum II|[Python](python/113 Path Sum II.py) [Java]()|Medium|| +|114|Flatten Binary Tree to Linked List|[Python](python/114 Flatten Binary Tree to Linked List.py) [Java]()|Medium|| +|116|Populating Next Right Pointers in Each Node|[Python](python/116 Populating Next Right Pointers in Each Node.py) [Java]()|Medium|| +|117|Populating Next Right Pointers in Each Node II|[Python](python/117 Populating Next Right Pointers in Each Node II.py) [Java]()|Medium|| +|124|Binary Tree Maximum Path Sum|[Python](python/124 Binary Tree Maximum Path Sum.py) [Java]()|Hard|| +|129|Sum Root to Leaf Numbers|[Python](python/129 Sum Root to Leaf Numbers.py) [Java]()|Medium|| +|144|Binary Tree Preorder Traversal|[Python](python/144 Binary Tree Preorder Traversal.py) [Java]()|Medium|| +|145|Binary Tree Postorder Traversal|[Python](python/145 Binary Tree Postorder Traversal.py) [Java]()|Hard|| +|156|Binary Tree Upside Down|[Python](python/156 Binary Tree Upside Down.py) [Java]()|Medium|| +|173|Binary Search Tree Iterator|[Python](python/173 Binary Search Tree Iterator.py) [Java]()|Medium|| +|199|Binary Tree Right Side View|[Python](python/199 Binary Tree Right Side View.py) [Java]()|Medium|| +|222|Count Complete Tree Nodes|[Python](python/222 Count Complete Tree Nodes.py) [Java]()|Medium|| +|226|Invert Binary Tree|[Python](python/226 Invert Binary Tree.py) [Java]()|Easy|| +|230|Kth Smallest Element in a BST|[Python](python/230 Kth Smallest Element in a BST.py) [Java]()|Medium|| +|235|Lowest Common Ancestor of a Binary Search Tree|[Python](python/235 Lowest Common Ancestor of a Binary Search Tree.py) [Java]()|Easy|| +|236|Lowest Common Ancestor of a Binary Tree|[Python](python/236 Lowest Common Ancestor of a Binary Tree.py) [Java]()|Medium|| +|250|Count Univalue Subtrees|[Python](python/250 Count Univalue Subtrees.py) [Java]()|Medium|| +|255|Verify Preorder Sequence in Binary Search Tree|[Python](python/255 Verify Preorder Sequence in Binary Search Tree.py) [Java]()|Medium|| +|257|Binary Tree Paths|[Python](python/257 Binary Tree Paths.py) [Java]()|Easy|| +|270|Closest Binary Search Tree Value|[Python](python/270 Closest Binary Search Tree Value.py) [Java]()|Easy|| +|272|Closest Binary Search Tree Value II|[Python](python/272 Closest Binary Search Tree Value II.py) [Java]()|Hard|| +|285|Inorder Successor in BST|[Python](python/285 Inorder Successor in BST.py) [Java]()|Medium|| +|297|Serialize and Deserialize Binary Tree|[Python](python/297 Serialize and Deserialize Binary Tree.py) [Java]()|Hard|| +|298|Binary Tree Longest Consecutive Sequence|[Python](python/298 Binary Tree Longest Consecutive Sequence.py) [Java]()|Medium|| +|333|Largest BST Subtree|[Python](python/333 Largest BST Subtree.py) [Java]()|Medium|| +|337|House Robber III|[Python](python/337 House Robber III.py) [Java]()|Medium|| +|366|Find Leaves of Binary Tree|[Python](python/366 Find Leaves of Binary Tree.py) [Java]()|Medium|| +|404|Sum of Left Leaves|[Python](python/404 Sum of Left Leaves.py) [Java]()|Easy|| +|437|Path Sum III|[Python](python/437 Path Sum III.py) [Java]()|Easy|| +|449|Serialize and Deserialize BST|[Python](python/449 Serialize and Deserialize BST.py) [Java]()|Medium|| +|450|Delete Node in a BST|[Python](python/450 Delete Node in a BST.py) [Java]()|Medium|| +|501|Find Mode in Binary Search Tree|[Python](python/501 Find Mode in Binary Search Tree.py) [Java]()|Easy|| +|508|Most Frequent Subtree Sum|[Python](python/508 Most Frequent Subtree Sum.py) [Java]()|Medium|| +|513|Find Bottom Left Tree Value|[Python](python/513 Find Bottom Left Tree Value.py) [Java]()|Medium|| +|515|Find Largest Value in Each Tree Row|[Python](python/515 Find Largest Value in Each Tree Row.py) [Java]()|Medium|| +|536|Construct Binary Tree from String|[Python](python/536 Construct Binary Tree from String.py) [Java]()|Medium|| +|538|Convert BST to Greater Tree|[Python](python/538 Convert BST to Greater Tree.py) [Java]()|Medium|| +|543|Diameter of Binary Tree|[Python](python/543 Diameter of Binary Tree.py) [Java]()|Easy|| +|545|Boundary of Binary Tree|[Python](python/545 Boundary of Binary Tree.py) [Java]()|Medium|| +|549|Binary Tree Longest Consecutive Sequence II|[Python](python/549 Binary Tree Longest Consecutive Sequence II.py) [Java]()|Medium|| +|563|Binary Tree Tilt|[Python](python/563 Binary Tree Tilt.py) [Java]()|Easy|| + +## Depth-first Search + +| # | Title | Solution | Difficulty | Note | +|-----|---------------- | --------------- | --------------- | --------------- | +|98|Validate Binary Search Tree|[Python](python/098 Validate Binary Search Tree.py) [Java]()|Medium|| +|99|Recover Binary Search Tree|[Python](python/099 Recover Binary Search Tree.py) [Java]()|Hard|| +|100|Same Tree|[Python](python/100 Same Tree.py) [Java]()|Easy|| +|101|Symmetric Tree|[Python](python/101 Symmetric Tree.py) [Java]()|Easy|| +|104|Maximum Depth of Binary Tree|[Python](python/104 Maximum Depth of Binary Tree.py) [Java]()|Easy|| +|105|Construct Binary Tree from Preorder and Inorder Traversal|[Python](python/105 Construct Binary Tree from Preorder and Inorder Traversal.py) [Java]()|Medium|| +|106|Construct Binary Tree from Inorder and Postorder Traversal|[Python](python/106 Construct Binary Tree from Inorder and Postorder Traversal.py) [Java]()|Medium|| +|108|Convert Sorted Array to Binary Search Tree|[Python](python/108 Convert Sorted Array to Binary Search Tree.py) [Java]()|Easy|| +|109|Convert Sorted List to Binary Search Tree|[Python](python/109 Convert Sorted List to Binary Search Tree.py) [Java]()|Medium|| +|110|Balanced Binary Tree|[Python](python/110 Balanced Binary Tree.py) [Java]()|Easy|| +|111|Minimum Depth of Binary Tree|[Python](python/111 Minimum Depth of Binary Tree.py) [Java]()|Easy|| +|112|Path Sum|[Python](python/112 Path Sum.py) [Java]()|Easy|| +|113|Path Sum II|[Python](python/113 Path Sum II.py) [Java]()|Medium|| +|114|Flatten Binary Tree to Linked List|[Python](python/114 Flatten Binary Tree to Linked List.py) [Java]()|Medium|| +|116|Populating Next Right Pointers in Each Node|[Python](python/116 Populating Next Right Pointers in Each Node.py) [Java]()|Medium|| +|117|Populating Next Right Pointers in Each Node II|[Python](python/117 Populating Next Right Pointers in Each Node II.py) [Java]()|Medium|| +|124|Binary Tree Maximum Path Sum|[Python](python/124 Binary Tree Maximum Path Sum.py) [Java]()|Hard|| +|129|Sum Root to Leaf Numbers|[Python](python/129 Sum Root to Leaf Numbers.py) [Java]()|Medium|| +|133|Clone Graph|[Python](python/133 Clone Graph.py) [Java]()|Medium|| +|199|Binary Tree Right Side View|[Python](python/199 Binary Tree Right Side View.py) [Java]()|Medium|| +|200|Number of Islands|[Python](python/200 Number of Islands.py) [Java]()|Medium|| +|207|Course Schedule|[Python](python/207 Course Schedule.py) [Java]()|Medium|| +|210|Course Schedule II|[Python](python/210 Course Schedule II.py) [Java]()|Medium|| +|257|Binary Tree Paths|[Python](python/257 Binary Tree Paths.py) [Java]()|Easy|| +|261|Graph Valid Tree|[Python](python/261 Graph Valid Tree.py) [Java]()|Medium|| +|301|Remove Invalid Parentheses|[Python](python/301 Remove Invalid Parentheses.py) [Java]()|Hard|| +|323|Number of Connected Components in an Undirected Graph|[Python](python/323 Number of Connected Components in an Undirected Graph.py) [Java]()|Medium|| +|329|Longest Increasing Path in a Matrix|[Python](python/329 Longest Increasing Path in a Matrix.py) [Java]()|Hard|| +|332|Reconstruct Itinerary|[Python](python/332 Reconstruct Itinerary.py) [Java]()|Medium|| +|337|House Robber III|[Python](python/337 House Robber III.py) [Java]()|Medium|| +|339|Nested List Weight Sum|[Python](python/339 Nested List Weight Sum.py) [Java]()|Easy|| +|364|Nested List Weight Sum II|[Python](python/364 Nested List Weight Sum II.py) [Java]()|Medium|| +|366|Find Leaves of Binary Tree|[Python](python/366 Find Leaves of Binary Tree.py) [Java]()|Medium|| +|394|Decode String|[Python](python/394 Decode String.py) [Java]()|Medium|| +|417|Pacific Atlantic Water Flow|[Python](python/417 Pacific Atlantic Water Flow.py) [Java]()|Medium|| +|439|Ternary Expression Parser|[Python](python/439 Ternary Expression Parser.py) [Java]()|Medium|| +|472|Concatenated Words|[Python](python/472 Concatenated Words.py) [Java]()|Hard|| +|473|Matchsticks to Square|[Python](python/473 Matchsticks to Square.py) [Java]()|Medium|| +|488|Zuma Game|[Python](python/488 Zuma Game.py) [Java]()|Hard|| +|490|The Maze|[Python](python/490 The Maze.py) [Java]()|Medium|| +|491|Increasing Subsequences|[Python](python/491 Increasing Subsequences.py) [Java]()|Medium|| +|494|Target Sum|[Python](python/494 Target Sum.py) [Java]()|Medium|| +|499|The Maze III|[Python](python/499 The Maze III.py) [Java]()|Hard|| +|505|The Maze II|[Python](python/505 The Maze II.py) [Java]()|Medium|| +|513|Find Bottom Left Tree Value|[Python](python/513 Find Bottom Left Tree Value.py) [Java]()|Medium|| +|514|Freedom Trail|[Python](python/514 Freedom Trail.py) [Java]()|Hard|| +|515|Find Largest Value in Each Tree Row|[Python](python/515 Find Largest Value in Each Tree Row.py) [Java]()|Medium|| +|529|Minesweeper|[Python](python/529 Minesweeper.py) [Java]()|Medium|| +|531|Lonely Pixel I|[Python](python/531 Lonely Pixel I.py) [Java]()|Medium|| +|533|Lonely Pixel II|[Python](python/533 Lonely Pixel II.py) [Java]()|Medium|| +|542|01 Matrix|[Python](python/542 01 Matrix.py) [Java]()|Medium|| +|546|Remove Boxes|[Python](python/546 Remove Boxes.py) [Java]()|Hard|| +|547|Friend Circles|[Python](python/547 Friend Circles.py) [Java]()|Medium|| + +## Breadth-first Search + +| # | Title | Solution | Difficulty | Note | +|-----|---------------- | --------------- | --------------- | --------------- | +|101|Symmetric Tree|[Python](python/101 Symmetric Tree.py) [Java]()|Easy|| +|102|Binary Tree Level Order Traversal|[Python](python/102 Binary Tree Level Order Traversal.py) [Java]()|Medium|| +|103|Binary Tree Zigzag Level Order Traversal|[Python](python/103 Binary Tree Zigzag Level Order Traversal.py) [Java]()|Medium|| +|107|Binary Tree Level Order Traversal II|[Python](python/107 Binary Tree Level Order Traversal II.py) [Java]()|Easy|| +|111|Minimum Depth of Binary Tree|[Python](python/111 Minimum Depth of Binary Tree.py) [Java]()|Easy|| +|126|Word Ladder II|[Python](python/126 Word Ladder II.py) [Java]()|Hard|| +|130|Surrounded Regions|[Python](python/130 Surrounded Regions.py) [Java]()|Medium|| +|133|Clone Graph|[Python](python/133 Clone Graph.py) [Java]()|Medium|| +|199|Binary Tree Right Side View|[Python](python/199 Binary Tree Right Side View.py) [Java]()|Medium|| +|200|Number of Islands|[Python](python/200 Number of Islands.py) [Java]()|Medium|| +|207|Course Schedule|[Python](python/207 Course Schedule.py) [Java]()|Medium|| +|210|Course Schedule II|[Python](python/210 Course Schedule II.py) [Java]()|Medium|| +|261|Graph Valid Tree|[Python](python/261 Graph Valid Tree.py) [Java]()|Medium|| +|279|Perfect Squares|[Python](python/279 Perfect Squares.py) [Java]()|Medium|| +|286|Walls and Gates|[Python](python/286 Walls and Gates.py) [Java]()|Medium|| +|301|Remove Invalid Parentheses|[Python](python/301 Remove Invalid Parentheses.py) [Java]()|Hard|| +|310|Minimum Height Trees|[Python](python/310 Minimum Height Trees.py) [Java]()|Medium|| +|317|Shortest Distance from All Buildings|[Python](python/317 Shortest Distance from All Buildings.py) [Java]()|Hard|| +|323|Number of Connected Components in an Undirected Graph|[Python](python/323 Number of Connected Components in an Undirected Graph.py) [Java]()|Medium|| +|407|Trapping Rain Water II|[Python](python/407 Trapping Rain Water II.py) [Java]()|Hard|| +|417|Pacific Atlantic Water Flow|[Python](python/417 Pacific Atlantic Water Flow.py) [Java]()|Medium|| +|490|The Maze|[Python](python/490 The Maze.py) [Java]()|Medium|| +|499|The Maze III|[Python](python/499 The Maze III.py) [Java]()|Hard|| +|505|The Maze II|[Python](python/505 The Maze II.py) [Java]()|Medium|| +|513|Find Bottom Left Tree Value|[Python](python/513 Find Bottom Left Tree Value.py) [Java]()|Medium|| +|515|Find Largest Value in Each Tree Row|[Python](python/515 Find Largest Value in Each Tree Row.py) [Java]()|Medium|| +|529|Minesweeper|[Python](python/529 Minesweeper.py) [Java]()|Medium|| +|542|01 Matrix|[Python](python/542 01 Matrix.py) [Java]()|Medium|| + +## Union Find + +| # | Title | Solution | Difficulty | Note | +|-----|---------------- | --------------- | --------------- | --------------- | +|128|Longest Consecutive Sequence|[Python](python/128 Longest Consecutive Sequence.py) [Java]()|Hard|| +|130|Surrounded Regions|[Python](python/130 Surrounded Regions.py) [Java]()|Medium|| +|200|Number of Islands|[Python](python/200 Number of Islands.py) [Java]()|Medium|| +|261|Graph Valid Tree|[Python](python/261 Graph Valid Tree.py) [Java]()|Medium|| +|305|Number of Islands II|[Python](python/305 Number of Islands II.py) [Java]()|Hard|| +|323|Number of Connected Components in an Undirected Graph|[Python](python/323 Number of Connected Components in an Undirected Graph.py) [Java]()|Medium|| +|547|Friend Circles|[Python](python/547 Friend Circles.py) [Java]()|Medium|| + +## Graph + +| # | Title | Solution | Difficulty | Note | +|-----|---------------- | --------------- | --------------- | --------------- | +|133|Clone Graph|[Python](python/133 Clone Graph.py) [Java]()|Medium|| +|207|Course Schedule|[Python](python/207 Course Schedule.py) [Java]()|Medium|| +|210|Course Schedule II|[Python](python/210 Course Schedule II.py) [Java]()|Medium|| +|261|Graph Valid Tree|[Python](python/261 Graph Valid Tree.py) [Java]()|Medium|| +|269|Alien Dictionary|[Python](python/269 Alien Dictionary.py) [Java]()|Hard|| +|310|Minimum Height Trees|[Python](python/310 Minimum Height Trees.py) [Java]()|Medium|| +|323|Number of Connected Components in an Undirected Graph|[Python](python/323 Number of Connected Components in an Undirected Graph.py) [Java]()|Medium|| +|332|Reconstruct Itinerary|[Python](python/332 Reconstruct Itinerary.py) [Java]()|Medium|| +|399|Evaluate Division|[Python](python/399 Evaluate Division.py) [Java]()|Medium|| +|444|Sequence Reconstruction|[Python](python/444 Sequence Reconstruction.py) [Java]()|Medium|| + +## Design + +| # | Title | Solution | Difficulty | Note | +|-----|---------------- | --------------- | --------------- | --------------- | +|146|LRU Cache|[Python](python/146 LRU Cache.py) [Java]()|Hard|| +|155|Min Stack|[Python](python/155 Min Stack.py) [Java]()|Easy|| +|170|Two Sum III - Data structure design|[Python](python/170 Two Sum III - Data structure design.py) [Java]()|Easy|| +|173|Binary Search Tree Iterator|[Python](python/173 Binary Search Tree Iterator.py) [Java]()|Medium|| +|208|Implement Trie (Prefix Tree)|[Python](python/208 Implement Trie (Prefix Tree).py) [Java]()|Medium|| +|211|Add and Search Word - Data structure design|[Python](python/211 Add and Search Word - Data structure design.py) [Java]()|Medium|| +|225|Implement Stack using Queues|[Python](python/225 Implement Stack using Queues.py) [Java]()|Easy|| +|232|Implement Queue using Stacks|[Python](python/232 Implement Queue using Stacks.py) [Java]()|Easy|| +|244|Shortest Word Distance II|[Python](python/244 Shortest Word Distance II.py) [Java]()|Medium|| +|251|Flatten 2D Vector|[Python](python/251 Flatten 2D Vector.py) [Java]()|Medium|| +|281|Zigzag Iterator|[Python](python/281 Zigzag Iterator.py) [Java]()|Medium|| +|284|Peeking Iterator|[Python](python/284 Peeking Iterator.py) [Java]()|Medium|| +|288|Unique Word Abbreviation|[Python](python/288 Unique Word Abbreviation.py) [Java]()|Medium|| +|295|Find Median from Data Stream|[Python](python/295 Find Median from Data Stream.py) [Java]()|Hard|| +|297|Serialize and Deserialize Binary Tree|[Python](python/297 Serialize and Deserialize Binary Tree.py) [Java]()|Hard|| +|341|Flatten Nested List Iterator|[Python](python/341 Flatten Nested List Iterator.py) [Java]()|Medium|| +|346|Moving Average from Data Stream|[Python](python/346 Moving Average from Data Stream.py) [Java]()|Easy|| +|348|Design Tic-Tac-Toe|[Python](python/348 Design Tic-Tac-Toe.py) [Java]()|Medium|| +|353|Design Snake Game|[Python](python/353 Design Snake Game.py) [Java]()|Medium|| +|355|Design Twitter|[Python](python/355 Design Twitter.py) [Java]()|Medium|| +|359|Logger Rate Limiter|[Python](python/359 Logger Rate Limiter.py) [Java]()|Easy|| +|362|Design Hit Counter|[Python](python/362 Design Hit Counter.py) [Java]()|Medium|| +|379|Design Phone Directory|[Python](python/379 Design Phone Directory.py) [Java]()|Medium|| +|380|Insert Delete GetRandom O(1)|[Python](python/380 Insert Delete GetRandom O(1).py) [Java]()|Medium|| +|381|Insert Delete GetRandom O(1) - Duplicates allowed|[Python](python/381 Insert Delete GetRandom O(1) - Duplicates allowed.py) [Java]()|Hard|| +|432|All O`one Data Structure|[Python](python/432 All O`one Data Structure.py) [Java]()|Hard|| +|460|LFU Cache|[Python](python/460 LFU Cache.py) [Java]()|Hard|| + +## Topological Sort + +| # | Title | Solution | Difficulty | Note | +|-----|---------------- | --------------- | --------------- | --------------- | +|207|Course Schedule|[Python](python/207 Course Schedule.py) [Java]()|Medium|| +|210|Course Schedule II|[Python](python/210 Course Schedule II.py) [Java]()|Medium|| +|269|Alien Dictionary|[Python](python/269 Alien Dictionary.py) [Java]()|Hard|| +|329|Longest Increasing Path in a Matrix|[Python](python/329 Longest Increasing Path in a Matrix.py) [Java]()|Hard|| +|444|Sequence Reconstruction|[Python](python/444 Sequence Reconstruction.py) [Java]()|Medium|| + +## Trie + +| # | Title | Solution | Difficulty | Note | +|-----|---------------- | --------------- | --------------- | --------------- | +|208|Implement Trie (Prefix Tree)|[Python](python/208 Implement Trie (Prefix Tree).py) [Java]()|Medium|| +|211|Add and Search Word - Data structure design|[Python](python/211 Add and Search Word - Data structure design.py) [Java]()|Medium|| +|212|Word Search II|[Python](python/212 Word Search II.py) [Java]()|Hard|| +|336|Palindrome Pairs|[Python](python/336 Palindrome Pairs.py) [Java]()|Hard|| +|421|Maximum XOR of Two Numbers in an Array|[Python](python/421 Maximum XOR of Two Numbers in an Array.py) [Java]()|Medium|| +|425|Word Squares|[Python](python/425 Word Squares.py) [Java]()|Hard|| +|472|Concatenated Words|[Python](python/472 Concatenated Words.py) [Java]()|Hard|| + +## Binary Indexed Tree + +| # | Title | Solution | Difficulty | Note | +|-----|---------------- | --------------- | --------------- | --------------- | +|218|The Skyline Problem|[Python](python/218 The Skyline Problem.py) [Java]()|Hard|| +|307|Range Sum Query - Mutable|[Python](python/307 Range Sum Query - Mutable.py) [Java]()|Medium|| +|308|Range Sum Query 2D - Mutable|[Python](python/308 Range Sum Query 2D - Mutable.py) [Java]()|Hard|| +|315|Count of Smaller Numbers After Self|[Python](python/315 Count of Smaller Numbers After Self.py) [Java]()|Hard|| +|493|Reverse Pairs|[Python](python/493 Reverse Pairs.py) [Java]()|Hard|| + +## Segment Tree + +| # | Title | Solution | Difficulty | Note | +|-----|---------------- | --------------- | --------------- | --------------- | +|218|The Skyline Problem|[Python](python/218 The Skyline Problem.py) [Java]()|Hard|| +|307|Range Sum Query - Mutable|[Python](python/307 Range Sum Query - Mutable.py) [Java]()|Medium|| +|308|Range Sum Query 2D - Mutable|[Python](python/308 Range Sum Query 2D - Mutable.py) [Java]()|Hard|| +|315|Count of Smaller Numbers After Self|[Python](python/315 Count of Smaller Numbers After Self.py) [Java]()|Hard|| +|493|Reverse Pairs|[Python](python/493 Reverse Pairs.py) [Java]()|Hard|| + +## Binary Search Tree + +| # | Title | Solution | Difficulty | Note | +|-----|---------------- | --------------- | --------------- | --------------- | +|220|Contains Duplicate III|[Python](python/220 Contains Duplicate III.py) [Java]()|Medium|| +|315|Count of Smaller Numbers After Self|[Python](python/315 Count of Smaller Numbers After Self.py) [Java]()|Hard|| +|327|Count of Range Sum|[Python](python/327 Count of Range Sum.py) [Java]()|Hard|| +|352|Data Stream as Disjoint Intervals|[Python](python/352 Data Stream as Disjoint Intervals.py) [Java]()|Hard|| +|493|Reverse Pairs|[Python](python/493 Reverse Pairs.py) [Java]()|Hard|| +|530|Minimum Absolute Difference in BST|[Python](python/530 Minimum Absolute Difference in BST.py) [Java]()|Easy|| + +## Recursion + +| # | Title | Solution | Difficulty | Note | +|-----|---------------- | --------------- | --------------- | --------------- | +|247|Strobogrammatic Number II|[Python](python/247 Strobogrammatic Number II.py) [Java]()|Medium|| +|248|Strobogrammatic Number III|[Python](python/248 Strobogrammatic Number III.py) [Java]()|Hard|| +|544|Output Contest Matches|[Python](python/544 Output Contest Matches.py) [Java]()|Medium|| + +## Brainteaser + +| # | Title | Solution | Difficulty | Note | +|-----|---------------- | --------------- | --------------- | --------------- | +|292|Nim Game|[Python](python/292 Nim Game.py) [Java]()|Easy|| +|319|Bulb Switcher|[Python](python/319 Bulb Switcher.py) [Java]()|Medium|| + +## Memoization + +| # | Title | Solution | Difficulty | Note | +|-----|---------------- | --------------- | --------------- | --------------- | +|329|Longest Increasing Path in a Matrix|[Python](python/329 Longest Increasing Path in a Matrix.py) [Java]()|Hard|| + +## Queue + +| # | Title | Solution | Difficulty | Note | +|-----|---------------- | --------------- | --------------- | --------------- | +|346|Moving Average from Data Stream|[Python](python/346 Moving Average from Data Stream.py) [Java]()|Easy|| +|353|Design Snake Game|[Python](python/353 Design Snake Game.py) [Java]()|Medium|| +|363|Max Sum of Rectangle No Larger Than K|[Python](python/363 Max Sum of Rectangle No Larger Than K.py) [Java]()|Hard|| + +## Minimax + +| # | Title | Solution | Difficulty | Note | +|-----|---------------- | --------------- | --------------- | --------------- | +|375|Guess Number Higher or Lower II|[Python](python/375 Guess Number Higher or Lower II.py) [Java]()|Medium|| +|464|Can I Win|[Python](python/464 Can I Win.py) [Java]()|Medium|| +|486|Predict the Winner|[Python](python/486 Predict the Winner.py) [Java]()|Medium|| + +## Reservoir Sampling + +| # | Title | Solution | Difficulty | Note | +|-----|---------------- | --------------- | --------------- | --------------- | +|382|Linked List Random Node|[Python](python/382 Linked List Random Node.py) [Java]()|Medium|| +|398|Random Pick Index|[Python](python/398 Random Pick Index.py) [Java]()|Medium|| \ No newline at end of file From 7e71de602f943858e42dd179a252eb159209d575 Mon Sep 17 00:00:00 2001 From: Shen Jie Date: Tue, 2 May 2017 16:11:32 +0800 Subject: [PATCH 12/53] Add links for each problems --- TAG.md | 1542 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 771 insertions(+), 771 deletions(-) diff --git a/TAG.md b/TAG.md index 3691dee..6a606cd 100644 --- a/TAG.md +++ b/TAG.md @@ -34,914 +34,914 @@ | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|1|Two Sum|[Python](python/001 Two Sum.py) [Java]()|Easy|| -|4|Median of Two Sorted Arrays|[Python](python/004 Median of Two Sorted Arrays.py) [Java]()|Hard|| -|11|Container With Most Water|[Python](python/011 Container With Most Water.py) [Java]()|Medium|| -|15|3Sum|[Python](python/015 3Sum.py) [Java]()|Medium|| -|16|3Sum Closest|[Python](python/016 3Sum Closest.py) [Java]()|Medium|| -|18|4Sum|[Python](python/018 4Sum.py) [Java]()|Medium|| -|26|Remove Duplicates from Sorted Array|[Python](python/026 Remove Duplicates from Sorted Array.py) [Java]()|Easy|| -|27|Remove Element|[Python](python/027 Remove Element.py) [Java]()|Easy|| -|31|Next Permutation|[Python](python/031 Next Permutation.py) [Java]()|Medium|| -|33|Search in Rotated Sorted Array|[Python](python/033 Search in Rotated Sorted Array.py) [Java]()|Medium|| -|34|Search for a Range|[Python](python/034 Search for a Range.py) [Java]()|Medium|| -|35|Search Insert Position|[Python](python/035 Search Insert Position.py) [Java]()|Easy|| -|39|Combination Sum|[Python](python/039 Combination Sum.py) [Java]()|Medium|| -|40|Combination Sum II|[Python](python/040 Combination Sum II.py) [Java]()|Medium|| -|41|First Missing Positive|[Python](python/041 First Missing Positive.py) [Java]()|Hard|| -|42|Trapping Rain Water|[Python](python/042 Trapping Rain Water.py) [Java]()|Hard|| -|45|Jump Game II|[Python](python/045 Jump Game II.py) [Java]()|Hard|| -|48|Rotate Image|[Python](python/048 Rotate Image.py) [Java]()|Medium|| -|53|Maximum Subarray|[Python](python/053 Maximum Subarray.py) [Java]()|Easy|| -|54|Spiral Matrix|[Python](python/054 Spiral Matrix.py) [Java]()|Medium|| -|55|Jump Game|[Python](python/055 Jump Game.py) [Java]()|Medium|| -|56|Merge Intervals|[Python](python/056 Merge Intervals.py) [Java]()|Medium|| -|57|Insert Interval|[Python](python/057 Insert Interval.py) [Java]()|Hard|| -|59|Spiral Matrix II|[Python](python/059 Spiral Matrix II.py) [Java]()|Medium|| -|62|Unique Paths|[Python](python/062 Unique Paths.py) [Java]()|Medium|| -|63|Unique Paths II|[Python](python/063 Unique Paths II.py) [Java]()|Medium|| -|64|Minimum Path Sum|[Python](python/064 Minimum Path Sum.py) [Java]()|Medium|| -|66|Plus One|[Python](python/066 Plus One.py) [Java]()|Easy|| -|73|Set Matrix Zeroes|[Python](python/073 Set Matrix Zeroes.py) [Java]()|Medium|| -|74|Search a 2D Matrix|[Python](python/074 Search a 2D Matrix.py) [Java]()|Medium|| -|75|Sort Colors|[Python](python/075 Sort Colors.py) [Java]()|Medium|| -|78|Subsets|[Python](python/078 Subsets.py) [Java]()|Medium|| -|79|Word Search|[Python](python/079 Word Search.py) [Java]()|Medium|| -|80|Remove Duplicates from Sorted Array II|[Python](python/080 Remove Duplicates from Sorted Array II.py) [Java]()|Medium|| -|81|Search in Rotated Sorted Array II|[Python](python/081 Search in Rotated Sorted Array II.py) [Java]()|Medium|| -|84|Largest Rectangle in Histogram|[Python](python/084 Largest Rectangle in Histogram.py) [Java]()|Hard|| -|85|Maximal Rectangle|[Python](python/085 Maximal Rectangle.py) [Java]()|Hard|| -|88|Merge Sorted Array|[Python](python/088 Merge Sorted Array.py) [Java]()|Easy|| -|90|Subsets II|[Python](python/090 Subsets II.py) [Java]()|Medium|| -|105|Construct Binary Tree from Preorder and Inorder Traversal|[Python](python/105 Construct Binary Tree from Preorder and Inorder Traversal.py) [Java]()|Medium|| -|106|Construct Binary Tree from Inorder and Postorder Traversal|[Python](python/106 Construct Binary Tree from Inorder and Postorder Traversal.py) [Java]()|Medium|| -|118|Pascal's Triangle|[Python](python/118 Pascal's Triangle.py) [Java]()|Easy|| -|119|Pascal's Triangle II|[Python](python/119 Pascal's Triangle II.py) [Java]()|Easy|| -|120|Triangle|[Python](python/120 Triangle.py) [Java]()|Medium|| -|121|Best Time to Buy and Sell Stock|[Python](python/121 Best Time to Buy and Sell Stock.py) [Java]()|Easy|| -|122|Best Time to Buy and Sell Stock II|[Python](python/122 Best Time to Buy and Sell Stock II.py) [Java]()|Easy|| -|123|Best Time to Buy and Sell Stock III|[Python](python/123 Best Time to Buy and Sell Stock III.py) [Java]()|Hard|| -|126|Word Ladder II|[Python](python/126 Word Ladder II.py) [Java]()|Hard|| -|128|Longest Consecutive Sequence|[Python](python/128 Longest Consecutive Sequence.py) [Java]()|Hard|| -|152|Maximum Product Subarray|[Python](python/152 Maximum Product Subarray.py) [Java]()|Medium|| -|153|Find Minimum in Rotated Sorted Array|[Python](python/153 Find Minimum in Rotated Sorted Array.py) [Java]()|Medium|| -|154|Find Minimum in Rotated Sorted Array II|[Python](python/154 Find Minimum in Rotated Sorted Array II.py) [Java]()|Hard|| -|162|Find Peak Element|[Python](python/162 Find Peak Element.py) [Java]()|Medium|| -|163|Missing Ranges|[Python](python/163 Missing Ranges.py) [Java]()|Medium|| -|167|Two Sum II - Input array is sorted|[Python](python/167 Two Sum II - Input array is sorted.py) [Java]()|Easy|| -|169|Majority Element|[Python](python/169 Majority Element.py) [Java]()|Easy|| -|189|Rotate Array|[Python](python/189 Rotate Array.py) [Java]()|Easy|| -|209|Minimum Size Subarray Sum|[Python](python/209 Minimum Size Subarray Sum.py) [Java]()|Medium|| -|216|Combination Sum III|[Python](python/216 Combination Sum III.py) [Java]()|Medium|| -|217|Contains Duplicate|[Python](python/217 Contains Duplicate.py) [Java]()|Easy|| -|219|Contains Duplicate II|[Python](python/219 Contains Duplicate II.py) [Java]()|Easy|| -|228|Summary Ranges|[Python](python/228 Summary Ranges.py) [Java]()|Medium|| -|229|Majority Element II|[Python](python/229 Majority Element II.py) [Java]()|Medium|| -|238|Product of Array Except Self|[Python](python/238 Product of Array Except Self.py) [Java]()|Medium|| -|243|Shortest Word Distance|[Python](python/243 Shortest Word Distance.py) [Java]()|Easy|| -|245|Shortest Word Distance III|[Python](python/245 Shortest Word Distance III.py) [Java]()|Medium|| -|259|3Sum Smaller|[Python](python/259 3Sum Smaller.py) [Java]()|Medium|| -|268|Missing Number|[Python](python/268 Missing Number.py) [Java]()|Easy|| -|277|Find the Celebrity|[Python](python/277 Find the Celebrity.py) [Java]()|Medium|| -|280|Wiggle Sort|[Python](python/280 Wiggle Sort.py) [Java]()|Medium|| -|283|Move Zeroes|[Python](python/283 Move Zeroes.py) [Java]()|Easy|| -|287|Find the Duplicate Number|[Python](python/287 Find the Duplicate Number.py) [Java]()|Medium|| -|289|Game of Life|[Python](python/289 Game of Life.py) [Java]()|Medium|| -|370|Range Addition|[Python](python/370 Range Addition.py) [Java]()|Medium|| -|380|Insert Delete GetRandom O(1)|[Python](python/380 Insert Delete GetRandom O(1).py) [Java]()|Medium|| -|381|Insert Delete GetRandom O(1) - Duplicates allowed|[Python](python/381 Insert Delete GetRandom O(1) - Duplicates allowed.py) [Java]()|Hard|| -|414|Third Maximum Number|[Python](python/414 Third Maximum Number.py) [Java]()|Easy|| -|442|Find All Duplicates in an Array|[Python](python/442 Find All Duplicates in an Array.py) [Java]()|Medium|| -|448|Find All Numbers Disappeared in an Array|[Python](python/448 Find All Numbers Disappeared in an Array.py) [Java]()|Easy|| -|485|Max Consecutive Ones|[Python](python/485 Max Consecutive Ones.py) [Java]()|Easy|| -|495|Teemo Attacking|[Python](python/495 Teemo Attacking.py) [Java]()|Medium|| -|531|Lonely Pixel I|[Python](python/531 Lonely Pixel I.py) [Java]()|Medium|| -|532|K-diff Pairs in an Array|[Python](python/532 K-diff Pairs in an Array.py) [Java]()|Easy|| -|533|Lonely Pixel II|[Python](python/533 Lonely Pixel II.py) [Java]()|Medium|| -|548|Split Array with Equal Sum|[Python](python/548 Split Array with Equal Sum.py) [Java]()|Medium|| -|560|Subarray Sum Equals K|[Python](python/560 Subarray Sum Equals K.py) [Java]()|Medium|| -|561|Array Partition I|[Python](python/561 Array Partition I.py) [Java]()|Easy|| -|562|Longest Line of Consecutive One in Matrix|[Python](python/562 Longest Line of Consecutive One in Matrix.py) [Java]()|Medium|| -|566|Reshape the Matrix|[Python](python/566 Reshape the Matrix.py) [Java]()|Easy|| +|1|[Two Sum](https://leetcode.com/problems/two-sum)|[Python](./python/001 Two Sum.py) [Java]()|Easy|| +|4|[Median of Two Sorted Arrays](https://leetcode.com/problems/median-of-two-sorted-arrays)|[Python](./python/004 Median of Two Sorted Arrays.py) [Java]()|Hard|| +|11|[Container With Most Water](https://leetcode.com/problems/container-with-most-water)|[Python](./python/011 Container With Most Water.py) [Java]()|Medium|| +|15|[3Sum](https://leetcode.com/problems/3sum)|[Python](./python/015 3Sum.py) [Java]()|Medium|| +|16|[3Sum Closest](https://leetcode.com/problems/3sum-closest)|[Python](./python/016 3Sum Closest.py) [Java]()|Medium|| +|18|[4Sum](https://leetcode.com/problems/4sum)|[Python](./python/018 4Sum.py) [Java]()|Medium|| +|26|[Remove Duplicates from Sorted Array](https://leetcode.com/problems/remove-duplicates-from-sorted-array)|[Python](./python/026 Remove Duplicates from Sorted Array.py) [Java]()|Easy|| +|27|[Remove Element](https://leetcode.com/problems/remove-element)|[Python](./python/027 Remove Element.py) [Java]()|Easy|| +|31|[Next Permutation](https://leetcode.com/problems/next-permutation)|[Python](./python/031 Next Permutation.py) [Java]()|Medium|| +|33|[Search in Rotated Sorted Array](https://leetcode.com/problems/search-in-rotated-sorted-array)|[Python](./python/033 Search in Rotated Sorted Array.py) [Java]()|Medium|| +|34|[Search for a Range](https://leetcode.com/problems/search-for-a-range)|[Python](./python/034 Search for a Range.py) [Java]()|Medium|| +|35|[Search Insert Position](https://leetcode.com/problems/search-insert-position)|[Python](./python/035 Search Insert Position.py) [Java]()|Easy|| +|39|[Combination Sum](https://leetcode.com/problems/combination-sum)|[Python](./python/039 Combination Sum.py) [Java]()|Medium|| +|40|[Combination Sum II](https://leetcode.com/problems/combination-sum-ii)|[Python](./python/040 Combination Sum II.py) [Java]()|Medium|| +|41|[First Missing Positive](https://leetcode.com/problems/first-missing-positive)|[Python](./python/041 First Missing Positive.py) [Java]()|Hard|| +|42|[Trapping Rain Water](https://leetcode.com/problems/trapping-rain-water)|[Python](./python/042 Trapping Rain Water.py) [Java]()|Hard|| +|45|[Jump Game II](https://leetcode.com/problems/jump-game-ii)|[Python](./python/045 Jump Game II.py) [Java]()|Hard|| +|48|[Rotate Image](https://leetcode.com/problems/rotate-image)|[Python](./python/048 Rotate Image.py) [Java]()|Medium|| +|53|[Maximum Subarray](https://leetcode.com/problems/maximum-subarray)|[Python](./python/053 Maximum Subarray.py) [Java]()|Easy|| +|54|[Spiral Matrix](https://leetcode.com/problems/spiral-matrix)|[Python](./python/054 Spiral Matrix.py) [Java]()|Medium|| +|55|[Jump Game](https://leetcode.com/problems/jump-game)|[Python](./python/055 Jump Game.py) [Java]()|Medium|| +|56|[Merge Intervals](https://leetcode.com/problems/merge-intervals)|[Python](./python/056 Merge Intervals.py) [Java]()|Medium|| +|57|[Insert Interval](https://leetcode.com/problems/insert-interval)|[Python](./python/057 Insert Interval.py) [Java]()|Hard|| +|59|[Spiral Matrix II](https://leetcode.com/problems/spiral-matrix-ii)|[Python](./python/059 Spiral Matrix II.py) [Java]()|Medium|| +|62|[Unique Paths](https://leetcode.com/problems/unique-paths)|[Python](./python/062 Unique Paths.py) [Java]()|Medium|| +|63|[Unique Paths II](https://leetcode.com/problems/unique-paths-ii)|[Python](./python/063 Unique Paths II.py) [Java]()|Medium|| +|64|[Minimum Path Sum](https://leetcode.com/problems/minimum-path-sum)|[Python](./python/064 Minimum Path Sum.py) [Java]()|Medium|| +|66|[Plus One](https://leetcode.com/problems/plus-one)|[Python](./python/066 Plus One.py) [Java]()|Easy|| +|73|[Set Matrix Zeroes](https://leetcode.com/problems/set-matrix-zeroes)|[Python](./python/073 Set Matrix Zeroes.py) [Java]()|Medium|| +|74|[Search a 2D Matrix](https://leetcode.com/problems/search-a-2d-matrix)|[Python](./python/074 Search a 2D Matrix.py) [Java]()|Medium|| +|75|[Sort Colors](https://leetcode.com/problems/sort-colors)|[Python](./python/075 Sort Colors.py) [Java]()|Medium|| +|78|[Subsets](https://leetcode.com/problems/subsets)|[Python](./python/078 Subsets.py) [Java]()|Medium|| +|79|[Word Search](https://leetcode.com/problems/word-search)|[Python](./python/079 Word Search.py) [Java]()|Medium|| +|80|[Remove Duplicates from Sorted Array II](https://leetcode.com/problems/remove-duplicates-from-sorted-array-ii)|[Python](./python/080 Remove Duplicates from Sorted Array II.py) [Java]()|Medium|| +|81|[Search in Rotated Sorted Array II](https://leetcode.com/problems/search-in-rotated-sorted-array-ii)|[Python](./python/081 Search in Rotated Sorted Array II.py) [Java]()|Medium|| +|84|[Largest Rectangle in Histogram](https://leetcode.com/problems/largest-rectangle-in-histogram)|[Python](./python/084 Largest Rectangle in Histogram.py) [Java]()|Hard|| +|85|[Maximal Rectangle](https://leetcode.com/problems/maximal-rectangle)|[Python](./python/085 Maximal Rectangle.py) [Java]()|Hard|| +|88|[Merge Sorted Array](https://leetcode.com/problems/merge-sorted-array)|[Python](./python/088 Merge Sorted Array.py) [Java]()|Easy|| +|90|[Subsets II](https://leetcode.com/problems/subsets-ii)|[Python](./python/090 Subsets II.py) [Java]()|Medium|| +|105|[Construct Binary Tree from Preorder and Inorder Traversal](https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal)|[Python](./python/105 Construct Binary Tree from Preorder and Inorder Traversal.py) [Java]()|Medium|| +|106|[Construct Binary Tree from Inorder and Postorder Traversal](https://leetcode.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal)|[Python](./python/106 Construct Binary Tree from Inorder and Postorder Traversal.py) [Java]()|Medium|| +|118|[Pascal's Triangle](https://leetcode.com/problems/pascal's-triangle)|[Python](./python/118 Pascal's Triangle.py) [Java]()|Easy|| +|119|[Pascal's Triangle II](https://leetcode.com/problems/pascal's-triangle-ii)|[Python](./python/119 Pascal's Triangle II.py) [Java]()|Easy|| +|120|[Triangle](https://leetcode.com/problems/triangle)|[Python](./python/120 Triangle.py) [Java]()|Medium|| +|121|[Best Time to Buy and Sell Stock](https://leetcode.com/problems/best-time-to-buy-and-sell-stock)|[Python](./python/121 Best Time to Buy and Sell Stock.py) [Java]()|Easy|| +|122|[Best Time to Buy and Sell Stock II](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii)|[Python](./python/122 Best Time to Buy and Sell Stock II.py) [Java]()|Easy|| +|123|[Best Time to Buy and Sell Stock III](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iii)|[Python](./python/123 Best Time to Buy and Sell Stock III.py) [Java]()|Hard|| +|126|[Word Ladder II](https://leetcode.com/problems/word-ladder-ii)|[Python](./python/126 Word Ladder II.py) [Java]()|Hard|| +|128|[Longest Consecutive Sequence](https://leetcode.com/problems/longest-consecutive-sequence)|[Python](./python/128 Longest Consecutive Sequence.py) [Java]()|Hard|| +|152|[Maximum Product Subarray](https://leetcode.com/problems/maximum-product-subarray)|[Python](./python/152 Maximum Product Subarray.py) [Java]()|Medium|| +|153|[Find Minimum in Rotated Sorted Array](https://leetcode.com/problems/find-minimum-in-rotated-sorted-array)|[Python](./python/153 Find Minimum in Rotated Sorted Array.py) [Java]()|Medium|| +|154|[Find Minimum in Rotated Sorted Array II](https://leetcode.com/problems/find-minimum-in-rotated-sorted-array-ii)|[Python](./python/154 Find Minimum in Rotated Sorted Array II.py) [Java]()|Hard|| +|162|[Find Peak Element](https://leetcode.com/problems/find-peak-element)|[Python](./python/162 Find Peak Element.py) [Java]()|Medium|| +|163|[Missing Ranges](https://leetcode.com/problems/missing-ranges)|[Python](./python/163 Missing Ranges.py) [Java]()|Medium|| +|167|[Two Sum II - Input array is sorted](https://leetcode.com/problems/two-sum-ii---input-array-is-sorted)|[Python](./python/167 Two Sum II - Input array is sorted.py) [Java]()|Easy|| +|169|[Majority Element](https://leetcode.com/problems/majority-element)|[Python](./python/169 Majority Element.py) [Java]()|Easy|| +|189|[Rotate Array](https://leetcode.com/problems/rotate-array)|[Python](./python/189 Rotate Array.py) [Java]()|Easy|| +|209|[Minimum Size Subarray Sum](https://leetcode.com/problems/minimum-size-subarray-sum)|[Python](./python/209 Minimum Size Subarray Sum.py) [Java]()|Medium|| +|216|[Combination Sum III](https://leetcode.com/problems/combination-sum-iii)|[Python](./python/216 Combination Sum III.py) [Java]()|Medium|| +|217|[Contains Duplicate](https://leetcode.com/problems/contains-duplicate)|[Python](./python/217 Contains Duplicate.py) [Java]()|Easy|| +|219|[Contains Duplicate II](https://leetcode.com/problems/contains-duplicate-ii)|[Python](./python/219 Contains Duplicate II.py) [Java]()|Easy|| +|228|[Summary Ranges](https://leetcode.com/problems/summary-ranges)|[Python](./python/228 Summary Ranges.py) [Java]()|Medium|| +|229|[Majority Element II](https://leetcode.com/problems/majority-element-ii)|[Python](./python/229 Majority Element II.py) [Java]()|Medium|| +|238|[Product of Array Except Self](https://leetcode.com/problems/product-of-array-except-self)|[Python](./python/238 Product of Array Except Self.py) [Java]()|Medium|| +|243|[Shortest Word Distance](https://leetcode.com/problems/shortest-word-distance)|[Python](./python/243 Shortest Word Distance.py) [Java]()|Easy|| +|245|[Shortest Word Distance III](https://leetcode.com/problems/shortest-word-distance-iii)|[Python](./python/245 Shortest Word Distance III.py) [Java]()|Medium|| +|259|[3Sum Smaller](https://leetcode.com/problems/3sum-smaller)|[Python](./python/259 3Sum Smaller.py) [Java]()|Medium|| +|268|[Missing Number](https://leetcode.com/problems/missing-number)|[Python](./python/268 Missing Number.py) [Java]()|Easy|| +|277|[Find the Celebrity](https://leetcode.com/problems/find-the-celebrity)|[Python](./python/277 Find the Celebrity.py) [Java]()|Medium|| +|280|[Wiggle Sort](https://leetcode.com/problems/wiggle-sort)|[Python](./python/280 Wiggle Sort.py) [Java]()|Medium|| +|283|[Move Zeroes](https://leetcode.com/problems/move-zeroes)|[Python](./python/283 Move Zeroes.py) [Java]()|Easy|| +|287|[Find the Duplicate Number](https://leetcode.com/problems/find-the-duplicate-number)|[Python](./python/287 Find the Duplicate Number.py) [Java]()|Medium|| +|289|[Game of Life](https://leetcode.com/problems/game-of-life)|[Python](./python/289 Game of Life.py) [Java]()|Medium|| +|370|[Range Addition](https://leetcode.com/problems/range-addition)|[Python](./python/370 Range Addition.py) [Java]()|Medium|| +|380|[Insert Delete GetRandom O(1)](https://leetcode.com/problems/insert-delete-getrandom-o(1))|[Python](./python/380 Insert Delete GetRandom O(1).py) [Java]()|Medium|| +|381|[Insert Delete GetRandom O(1) - Duplicates allowed](https://leetcode.com/problems/insert-delete-getrandom-o(1)---duplicates-allowed)|[Python](./python/381 Insert Delete GetRandom O(1) - Duplicates allowed.py) [Java]()|Hard|| +|414|[Third Maximum Number](https://leetcode.com/problems/third-maximum-number)|[Python](./python/414 Third Maximum Number.py) [Java]()|Easy|| +|442|[Find All Duplicates in an Array](https://leetcode.com/problems/find-all-duplicates-in-an-array)|[Python](./python/442 Find All Duplicates in an Array.py) [Java]()|Medium|| +|448|[Find All Numbers Disappeared in an Array](https://leetcode.com/problems/find-all-numbers-disappeared-in-an-array)|[Python](./python/448 Find All Numbers Disappeared in an Array.py) [Java]()|Easy|| +|485|[Max Consecutive Ones](https://leetcode.com/problems/max-consecutive-ones)|[Python](./python/485 Max Consecutive Ones.py) [Java]()|Easy|| +|495|[Teemo Attacking](https://leetcode.com/problems/teemo-attacking)|[Python](./python/495 Teemo Attacking.py) [Java]()|Medium|| +|531|[Lonely Pixel I](https://leetcode.com/problems/lonely-pixel-i)|[Python](./python/531 Lonely Pixel I.py) [Java]()|Medium|| +|532|[K-diff Pairs in an Array](https://leetcode.com/problems/k-diff-pairs-in-an-array)|[Python](./python/532 K-diff Pairs in an Array.py) [Java]()|Easy|| +|533|[Lonely Pixel II](https://leetcode.com/problems/lonely-pixel-ii)|[Python](./python/533 Lonely Pixel II.py) [Java]()|Medium|| +|548|[Split Array with Equal Sum](https://leetcode.com/problems/split-array-with-equal-sum)|[Python](./python/548 Split Array with Equal Sum.py) [Java]()|Medium|| +|560|[Subarray Sum Equals K](https://leetcode.com/problems/subarray-sum-equals-k)|[Python](./python/560 Subarray Sum Equals K.py) [Java]()|Medium|| +|561|[Array Partition I](https://leetcode.com/problems/array-partition-i)|[Python](./python/561 Array Partition I.py) [Java]()|Easy|| +|562|[Longest Line of Consecutive One in Matrix](https://leetcode.com/problems/longest-line-of-consecutive-one-in-matrix)|[Python](./python/562 Longest Line of Consecutive One in Matrix.py) [Java]()|Medium|| +|566|[Reshape the Matrix](https://leetcode.com/problems/reshape-the-matrix)|[Python](./python/566 Reshape the Matrix.py) [Java]()|Easy|| ## Hash Table | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|1|Two Sum|[Python](python/001 Two Sum.py) [Java]()|Easy|| -|3|Longest Substring Without Repeating Characters|[Python](python/003 Longest Substring Without Repeating Characters.py) [Java]()|Medium|| -|18|4Sum|[Python](python/018 4Sum.py) [Java]()|Medium|| -|30|Substring with Concatenation of All Words|[Python](python/030 Substring with Concatenation of All Words.py) [Java]()|Hard|| -|36|Valid Sudoku|[Python](python/036 Valid Sudoku.py) [Java]()|Medium|| -|37|Sudoku Solver|[Python](python/037 Sudoku Solver.py) [Java]()|Hard|| -|49|Group Anagrams|[Python](python/049 Group Anagrams.py) [Java]()|Medium|| -|76|Minimum Window Substring|[Python](python/076 Minimum Window Substring.py) [Java]()|Hard|| -|85|Maximal Rectangle|[Python](python/085 Maximal Rectangle.py) [Java]()|Hard|| -|94|Binary Tree Inorder Traversal|[Python](python/094 Binary Tree Inorder Traversal.py) [Java]()|Medium|| -|136|Single Number|[Python](python/136 Single Number.py) [Java]()|Easy|| -|138|Copy List with Random Pointer|[Python](python/138 Copy List with Random Pointer.py) [Java]()|Medium|| -|149|Max Points on a Line|[Python](python/149 Max Points on a Line.py) [Java]()|Hard|| -|159|Longest Substring with At Most Two Distinct Characters|[Python](python/159 Longest Substring with At Most Two Distinct Characters.py) [Java]()|Hard|| -|166|Fraction to Recurring Decimal|[Python](python/166 Fraction to Recurring Decimal.py) [Java]()|Medium|| -|170|Two Sum III - Data structure design|[Python](python/170 Two Sum III - Data structure design.py) [Java]()|Easy|| -|187|Repeated DNA Sequences|[Python](python/187 Repeated DNA Sequences.py) [Java]()|Medium|| -|202|Happy Number|[Python](python/202 Happy Number.py) [Java]()|Easy|| -|204|Count Primes|[Python](python/204 Count Primes.py) [Java]()|Easy|| -|205|Isomorphic Strings|[Python](python/205 Isomorphic Strings.py) [Java]()|Easy|| -|217|Contains Duplicate|[Python](python/217 Contains Duplicate.py) [Java]()|Easy|| -|219|Contains Duplicate II|[Python](python/219 Contains Duplicate II.py) [Java]()|Easy|| -|242|Valid Anagram|[Python](python/242 Valid Anagram.py) [Java]()|Easy|| -|244|Shortest Word Distance II|[Python](python/244 Shortest Word Distance II.py) [Java]()|Medium|| -|246|Strobogrammatic Number|[Python](python/246 Strobogrammatic Number.py) [Java]()|Easy|| -|249|Group Shifted Strings|[Python](python/249 Group Shifted Strings.py) [Java]()|Medium|| -|266|Palindrome Permutation|[Python](python/266 Palindrome Permutation.py) [Java]()|Easy|| -|274|H-Index|[Python](python/274 H-Index.py) [Java]()|Medium|| -|288|Unique Word Abbreviation|[Python](python/288 Unique Word Abbreviation.py) [Java]()|Medium|| -|290|Word Pattern|[Python](python/290 Word Pattern.py) [Java]()|Easy|| -|299|Bulls and Cows|[Python](python/299 Bulls and Cows.py) [Java]()|Medium|| -|311|Sparse Matrix Multiplication|[Python](python/311 Sparse Matrix Multiplication.py) [Java]()|Medium|| -|314|Binary Tree Vertical Order Traversal|[Python](python/314 Binary Tree Vertical Order Traversal.py) [Java]()|Medium|| -|325|Maximum Size Subarray Sum Equals k|[Python](python/325 Maximum Size Subarray Sum Equals k.py) [Java]()|Medium|| -|336|Palindrome Pairs|[Python](python/336 Palindrome Pairs.py) [Java]()|Hard|| -|340|Longest Substring with At Most K Distinct Characters|[Python](python/340 Longest Substring with At Most K Distinct Characters.py) [Java]()|Hard|| -|347|Top K Frequent Elements|[Python](python/347 Top K Frequent Elements.py) [Java]()|Medium|| -|349|Intersection of Two Arrays|[Python](python/349 Intersection of Two Arrays.py) [Java]()|Easy|| -|350|Intersection of Two Arrays II|[Python](python/350 Intersection of Two Arrays II.py) [Java]()|Easy|| -|355|Design Twitter|[Python](python/355 Design Twitter.py) [Java]()|Medium|| -|356|Line Reflection|[Python](python/356 Line Reflection.py) [Java]()|Medium|| -|358|Rearrange String k Distance Apart|[Python](python/358 Rearrange String k Distance Apart.py) [Java]()|Hard|| -|359|Logger Rate Limiter|[Python](python/359 Logger Rate Limiter.py) [Java]()|Easy|| -|380|Insert Delete GetRandom O(1)|[Python](python/380 Insert Delete GetRandom O(1).py) [Java]()|Medium|| -|381|Insert Delete GetRandom O(1) - Duplicates allowed|[Python](python/381 Insert Delete GetRandom O(1) - Duplicates allowed.py) [Java]()|Hard|| -|389|Find the Difference|[Python](python/389 Find the Difference.py) [Java]()|Easy|| -|409|Longest Palindrome|[Python](python/409 Longest Palindrome.py) [Java]()|Easy|| -|438|Find All Anagrams in a String|[Python](python/438 Find All Anagrams in a String.py) [Java]()|Easy|| -|447|Number of Boomerangs|[Python](python/447 Number of Boomerangs.py) [Java]()|Easy|| -|451|Sort Characters By Frequency|[Python](python/451 Sort Characters By Frequency.py) [Java]()|Medium|| -|454|4Sum II|[Python](python/454 4Sum II.py) [Java]()|Medium|| -|463|Island Perimeter|[Python](python/463 Island Perimeter.py) [Java]()|Easy|| -|500|Keyboard Row|[Python](python/500 Keyboard Row.py) [Java]()|Easy|| -|508|Most Frequent Subtree Sum|[Python](python/508 Most Frequent Subtree Sum.py) [Java]()|Medium|| -|525|Contiguous Array|[Python](python/525 Contiguous Array.py) [Java]()|Medium|| -|535|Encode and Decode TinyURL|[Python](python/535 Encode and Decode TinyURL.py) [Java]()|Medium|| -|554|Brick Wall|[Python](python/554 Brick Wall.py) [Java]()|Medium|| +|1|[Two Sum](https://leetcode.com/problems/two-sum)|[Python](./python/001 Two Sum.py) [Java]()|Easy|| +|3|[Longest Substring Without Repeating Characters](https://leetcode.com/problems/longest-substring-without-repeating-characters)|[Python](./python/003 Longest Substring Without Repeating Characters.py) [Java]()|Medium|| +|18|[4Sum](https://leetcode.com/problems/4sum)|[Python](./python/018 4Sum.py) [Java]()|Medium|| +|30|[Substring with Concatenation of All Words](https://leetcode.com/problems/substring-with-concatenation-of-all-words)|[Python](./python/030 Substring with Concatenation of All Words.py) [Java]()|Hard|| +|36|[Valid Sudoku](https://leetcode.com/problems/valid-sudoku)|[Python](./python/036 Valid Sudoku.py) [Java]()|Medium|| +|37|[Sudoku Solver](https://leetcode.com/problems/sudoku-solver)|[Python](./python/037 Sudoku Solver.py) [Java]()|Hard|| +|49|[Group Anagrams](https://leetcode.com/problems/group-anagrams)|[Python](./python/049 Group Anagrams.py) [Java]()|Medium|| +|76|[Minimum Window Substring](https://leetcode.com/problems/minimum-window-substring)|[Python](./python/076 Minimum Window Substring.py) [Java]()|Hard|| +|85|[Maximal Rectangle](https://leetcode.com/problems/maximal-rectangle)|[Python](./python/085 Maximal Rectangle.py) [Java]()|Hard|| +|94|[Binary Tree Inorder Traversal](https://leetcode.com/problems/binary-tree-inorder-traversal)|[Python](./python/094 Binary Tree Inorder Traversal.py) [Java]()|Medium|| +|136|[Single Number](https://leetcode.com/problems/single-number)|[Python](./python/136 Single Number.py) [Java]()|Easy|| +|138|[Copy List with Random Pointer](https://leetcode.com/problems/copy-list-with-random-pointer)|[Python](./python/138 Copy List with Random Pointer.py) [Java]()|Medium|| +|149|[Max Points on a Line](https://leetcode.com/problems/max-points-on-a-line)|[Python](./python/149 Max Points on a Line.py) [Java]()|Hard|| +|159|[Longest Substring with At Most Two Distinct Characters](https://leetcode.com/problems/longest-substring-with-at-most-two-distinct-characters)|[Python](./python/159 Longest Substring with At Most Two Distinct Characters.py) [Java]()|Hard|| +|166|[Fraction to Recurring Decimal](https://leetcode.com/problems/fraction-to-recurring-decimal)|[Python](./python/166 Fraction to Recurring Decimal.py) [Java]()|Medium|| +|170|[Two Sum III - Data structure design](https://leetcode.com/problems/two-sum-iii---data-structure-design)|[Python](./python/170 Two Sum III - Data structure design.py) [Java]()|Easy|| +|187|[Repeated DNA Sequences](https://leetcode.com/problems/repeated-dna-sequences)|[Python](./python/187 Repeated DNA Sequences.py) [Java]()|Medium|| +|202|[Happy Number](https://leetcode.com/problems/happy-number)|[Python](./python/202 Happy Number.py) [Java]()|Easy|| +|204|[Count Primes](https://leetcode.com/problems/count-primes)|[Python](./python/204 Count Primes.py) [Java]()|Easy|| +|205|[Isomorphic Strings](https://leetcode.com/problems/isomorphic-strings)|[Python](./python/205 Isomorphic Strings.py) [Java]()|Easy|| +|217|[Contains Duplicate](https://leetcode.com/problems/contains-duplicate)|[Python](./python/217 Contains Duplicate.py) [Java]()|Easy|| +|219|[Contains Duplicate II](https://leetcode.com/problems/contains-duplicate-ii)|[Python](./python/219 Contains Duplicate II.py) [Java]()|Easy|| +|242|[Valid Anagram](https://leetcode.com/problems/valid-anagram)|[Python](./python/242 Valid Anagram.py) [Java]()|Easy|| +|244|[Shortest Word Distance II](https://leetcode.com/problems/shortest-word-distance-ii)|[Python](./python/244 Shortest Word Distance II.py) [Java]()|Medium|| +|246|[Strobogrammatic Number](https://leetcode.com/problems/strobogrammatic-number)|[Python](./python/246 Strobogrammatic Number.py) [Java]()|Easy|| +|249|[Group Shifted Strings](https://leetcode.com/problems/group-shifted-strings)|[Python](./python/249 Group Shifted Strings.py) [Java]()|Medium|| +|266|[Palindrome Permutation](https://leetcode.com/problems/palindrome-permutation)|[Python](./python/266 Palindrome Permutation.py) [Java]()|Easy|| +|274|[H-Index](https://leetcode.com/problems/h-index)|[Python](./python/274 H-Index.py) [Java]()|Medium|| +|288|[Unique Word Abbreviation](https://leetcode.com/problems/unique-word-abbreviation)|[Python](./python/288 Unique Word Abbreviation.py) [Java]()|Medium|| +|290|[Word Pattern](https://leetcode.com/problems/word-pattern)|[Python](./python/290 Word Pattern.py) [Java]()|Easy|| +|299|[Bulls and Cows](https://leetcode.com/problems/bulls-and-cows)|[Python](./python/299 Bulls and Cows.py) [Java]()|Medium|| +|311|[Sparse Matrix Multiplication](https://leetcode.com/problems/sparse-matrix-multiplication)|[Python](./python/311 Sparse Matrix Multiplication.py) [Java]()|Medium|| +|314|[Binary Tree Vertical Order Traversal](https://leetcode.com/problems/binary-tree-vertical-order-traversal)|[Python](./python/314 Binary Tree Vertical Order Traversal.py) [Java]()|Medium|| +|325|[Maximum Size Subarray Sum Equals k](https://leetcode.com/problems/maximum-size-subarray-sum-equals-k)|[Python](./python/325 Maximum Size Subarray Sum Equals k.py) [Java]()|Medium|| +|336|[Palindrome Pairs](https://leetcode.com/problems/palindrome-pairs)|[Python](./python/336 Palindrome Pairs.py) [Java]()|Hard|| +|340|[Longest Substring with At Most K Distinct Characters](https://leetcode.com/problems/longest-substring-with-at-most-k-distinct-characters)|[Python](./python/340 Longest Substring with At Most K Distinct Characters.py) [Java]()|Hard|| +|347|[Top K Frequent Elements](https://leetcode.com/problems/top-k-frequent-elements)|[Python](./python/347 Top K Frequent Elements.py) [Java]()|Medium|| +|349|[Intersection of Two Arrays](https://leetcode.com/problems/intersection-of-two-arrays)|[Python](./python/349 Intersection of Two Arrays.py) [Java]()|Easy|| +|350|[Intersection of Two Arrays II](https://leetcode.com/problems/intersection-of-two-arrays-ii)|[Python](./python/350 Intersection of Two Arrays II.py) [Java]()|Easy|| +|355|[Design Twitter](https://leetcode.com/problems/design-twitter)|[Python](./python/355 Design Twitter.py) [Java]()|Medium|| +|356|[Line Reflection](https://leetcode.com/problems/line-reflection)|[Python](./python/356 Line Reflection.py) [Java]()|Medium|| +|358|[Rearrange String k Distance Apart](https://leetcode.com/problems/rearrange-string-k-distance-apart)|[Python](./python/358 Rearrange String k Distance Apart.py) [Java]()|Hard|| +|359|[Logger Rate Limiter](https://leetcode.com/problems/logger-rate-limiter)|[Python](./python/359 Logger Rate Limiter.py) [Java]()|Easy|| +|380|[Insert Delete GetRandom O(1)](https://leetcode.com/problems/insert-delete-getrandom-o(1))|[Python](./python/380 Insert Delete GetRandom O(1).py) [Java]()|Medium|| +|381|[Insert Delete GetRandom O(1) - Duplicates allowed](https://leetcode.com/problems/insert-delete-getrandom-o(1)---duplicates-allowed)|[Python](./python/381 Insert Delete GetRandom O(1) - Duplicates allowed.py) [Java]()|Hard|| +|389|[Find the Difference](https://leetcode.com/problems/find-the-difference)|[Python](./python/389 Find the Difference.py) [Java]()|Easy|| +|409|[Longest Palindrome](https://leetcode.com/problems/longest-palindrome)|[Python](./python/409 Longest Palindrome.py) [Java]()|Easy|| +|438|[Find All Anagrams in a String](https://leetcode.com/problems/find-all-anagrams-in-a-string)|[Python](./python/438 Find All Anagrams in a String.py) [Java]()|Easy|| +|447|[Number of Boomerangs](https://leetcode.com/problems/number-of-boomerangs)|[Python](./python/447 Number of Boomerangs.py) [Java]()|Easy|| +|451|[Sort Characters By Frequency](https://leetcode.com/problems/sort-characters-by-frequency)|[Python](./python/451 Sort Characters By Frequency.py) [Java]()|Medium|| +|454|[4Sum II](https://leetcode.com/problems/4sum-ii)|[Python](./python/454 4Sum II.py) [Java]()|Medium|| +|463|[Island Perimeter](https://leetcode.com/problems/island-perimeter)|[Python](./python/463 Island Perimeter.py) [Java]()|Easy|| +|500|[Keyboard Row](https://leetcode.com/problems/keyboard-row)|[Python](./python/500 Keyboard Row.py) [Java]()|Easy|| +|508|[Most Frequent Subtree Sum](https://leetcode.com/problems/most-frequent-subtree-sum)|[Python](./python/508 Most Frequent Subtree Sum.py) [Java]()|Medium|| +|525|[Contiguous Array](https://leetcode.com/problems/contiguous-array)|[Python](./python/525 Contiguous Array.py) [Java]()|Medium|| +|535|[Encode and Decode TinyURL](https://leetcode.com/problems/encode-and-decode-tinyurl)|[Python](./python/535 Encode and Decode TinyURL.py) [Java]()|Medium|| +|554|[Brick Wall](https://leetcode.com/problems/brick-wall)|[Python](./python/554 Brick Wall.py) [Java]()|Medium|| ## Linked List | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|2|Add Two Numbers|[Python](python/002 Add Two Numbers.py) [Java]()|Medium|| -|19|Remove Nth Node From End of List|[Python](python/019 Remove Nth Node From End of List.py) [Java]()|Medium|| -|21|Merge Two Sorted Lists|[Python](python/021 Merge Two Sorted Lists.py) [Java]()|Easy|| -|23|Merge k Sorted Lists|[Python](python/023 Merge k Sorted Lists.py) [Java]()|Hard|| -|24|Swap Nodes in Pairs|[Python](python/024 Swap Nodes in Pairs.py) [Java]()|Medium|| -|25|Reverse Nodes in k-Group|[Python](python/025 Reverse Nodes in k-Group.py) [Java]()|Hard|| -|61|Rotate List|[Python](python/061 Rotate List.py) [Java]()|Medium|| -|82|Remove Duplicates from Sorted List II|[Python](python/082 Remove Duplicates from Sorted List II.py) [Java]()|Medium|| -|83|Remove Duplicates from Sorted List|[Python](python/083 Remove Duplicates from Sorted List.py) [Java]()|Easy|| -|86|Partition List|[Python](python/086 Partition List.py) [Java]()|Medium|| -|92|Reverse Linked List II|[Python](python/092 Reverse Linked List II.py) [Java]()|Medium|| -|109|Convert Sorted List to Binary Search Tree|[Python](python/109 Convert Sorted List to Binary Search Tree.py) [Java]()|Medium|| -|138|Copy List with Random Pointer|[Python](python/138 Copy List with Random Pointer.py) [Java]()|Medium|| -|141|Linked List Cycle|[Python](python/141 Linked List Cycle.py) [Java]()|Easy|| -|142|Linked List Cycle II|[Python](python/142 Linked List Cycle II.py) [Java]()|Medium|| -|143|Reorder List|[Python](python/143 Reorder List.py) [Java]()|Medium|| -|147|Insertion Sort List|[Python](python/147 Insertion Sort List.py) [Java]()|Medium|| -|148|Sort List|[Python](python/148 Sort List.py) [Java]()|Medium|| -|160|Intersection of Two Linked Lists|[Python](python/160 Intersection of Two Linked Lists.py) [Java]()|Easy|| -|203|Remove Linked List Elements|[Python](python/203 Remove Linked List Elements.py) [Java]()|Easy|| -|206|Reverse Linked List|[Python](python/206 Reverse Linked List.py) [Java]()|Easy|| -|234|Palindrome Linked List|[Python](python/234 Palindrome Linked List.py) [Java]()|Easy|| -|237|Delete Node in a Linked List|[Python](python/237 Delete Node in a Linked List.py) [Java]()|Easy|| -|328|Odd Even Linked List|[Python](python/328 Odd Even Linked List.py) [Java]()|Medium|| -|369|Plus One Linked List|[Python](python/369 Plus One Linked List.py) [Java]()|Medium|| -|379|Design Phone Directory|[Python](python/379 Design Phone Directory.py) [Java]()|Medium|| -|445|Add Two Numbers II|[Python](python/445 Add Two Numbers II.py) [Java]()|Medium|| +|2|[Add Two Numbers](https://leetcode.com/problems/add-two-numbers)|[Python](./python/002 Add Two Numbers.py) [Java]()|Medium|| +|19|[Remove Nth Node From End of List](https://leetcode.com/problems/remove-nth-node-from-end-of-list)|[Python](./python/019 Remove Nth Node From End of List.py) [Java]()|Medium|| +|21|[Merge Two Sorted Lists](https://leetcode.com/problems/merge-two-sorted-lists)|[Python](./python/021 Merge Two Sorted Lists.py) [Java]()|Easy|| +|23|[Merge k Sorted Lists](https://leetcode.com/problems/merge-k-sorted-lists)|[Python](./python/023 Merge k Sorted Lists.py) [Java]()|Hard|| +|24|[Swap Nodes in Pairs](https://leetcode.com/problems/swap-nodes-in-pairs)|[Python](./python/024 Swap Nodes in Pairs.py) [Java]()|Medium|| +|25|[Reverse Nodes in k-Group](https://leetcode.com/problems/reverse-nodes-in-k-group)|[Python](./python/025 Reverse Nodes in k-Group.py) [Java]()|Hard|| +|61|[Rotate List](https://leetcode.com/problems/rotate-list)|[Python](./python/061 Rotate List.py) [Java]()|Medium|| +|82|[Remove Duplicates from Sorted List II](https://leetcode.com/problems/remove-duplicates-from-sorted-list-ii)|[Python](./python/082 Remove Duplicates from Sorted List II.py) [Java]()|Medium|| +|83|[Remove Duplicates from Sorted List](https://leetcode.com/problems/remove-duplicates-from-sorted-list)|[Python](./python/083 Remove Duplicates from Sorted List.py) [Java]()|Easy|| +|86|[Partition List](https://leetcode.com/problems/partition-list)|[Python](./python/086 Partition List.py) [Java]()|Medium|| +|92|[Reverse Linked List II](https://leetcode.com/problems/reverse-linked-list-ii)|[Python](./python/092 Reverse Linked List II.py) [Java]()|Medium|| +|109|[Convert Sorted List to Binary Search Tree](https://leetcode.com/problems/convert-sorted-list-to-binary-search-tree)|[Python](./python/109 Convert Sorted List to Binary Search Tree.py) [Java]()|Medium|| +|138|[Copy List with Random Pointer](https://leetcode.com/problems/copy-list-with-random-pointer)|[Python](./python/138 Copy List with Random Pointer.py) [Java]()|Medium|| +|141|[Linked List Cycle](https://leetcode.com/problems/linked-list-cycle)|[Python](./python/141 Linked List Cycle.py) [Java]()|Easy|| +|142|[Linked List Cycle II](https://leetcode.com/problems/linked-list-cycle-ii)|[Python](./python/142 Linked List Cycle II.py) [Java]()|Medium|| +|143|[Reorder List](https://leetcode.com/problems/reorder-list)|[Python](./python/143 Reorder List.py) [Java]()|Medium|| +|147|[Insertion Sort List](https://leetcode.com/problems/insertion-sort-list)|[Python](./python/147 Insertion Sort List.py) [Java]()|Medium|| +|148|[Sort List](https://leetcode.com/problems/sort-list)|[Python](./python/148 Sort List.py) [Java]()|Medium|| +|160|[Intersection of Two Linked Lists](https://leetcode.com/problems/intersection-of-two-linked-lists)|[Python](./python/160 Intersection of Two Linked Lists.py) [Java]()|Easy|| +|203|[Remove Linked List Elements](https://leetcode.com/problems/remove-linked-list-elements)|[Python](./python/203 Remove Linked List Elements.py) [Java]()|Easy|| +|206|[Reverse Linked List](https://leetcode.com/problems/reverse-linked-list)|[Python](./python/206 Reverse Linked List.py) [Java]()|Easy|| +|234|[Palindrome Linked List](https://leetcode.com/problems/palindrome-linked-list)|[Python](./python/234 Palindrome Linked List.py) [Java]()|Easy|| +|237|[Delete Node in a Linked List](https://leetcode.com/problems/delete-node-in-a-linked-list)|[Python](./python/237 Delete Node in a Linked List.py) [Java]()|Easy|| +|328|[Odd Even Linked List](https://leetcode.com/problems/odd-even-linked-list)|[Python](./python/328 Odd Even Linked List.py) [Java]()|Medium|| +|369|[Plus One Linked List](https://leetcode.com/problems/plus-one-linked-list)|[Python](./python/369 Plus One Linked List.py) [Java]()|Medium|| +|379|[Design Phone Directory](https://leetcode.com/problems/design-phone-directory)|[Python](./python/379 Design Phone Directory.py) [Java]()|Medium|| +|445|[Add Two Numbers II](https://leetcode.com/problems/add-two-numbers-ii)|[Python](./python/445 Add Two Numbers II.py) [Java]()|Medium|| ## Math | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|2|Add Two Numbers|[Python](python/002 Add Two Numbers.py) [Java]()|Medium|| -|7|Reverse Integer|[Python](python/007 Reverse Integer.py) [Java]()|Easy|| -|8|String to Integer (atoi)|[Python](python/008 String to Integer (atoi).py) [Java]()|Medium|| -|9|Palindrome Number|[Python](python/009 Palindrome Number.py) [Java]()|Easy|| -|12|Integer to Roman|[Python](python/012 Integer to Roman.py) [Java]()|Medium|| -|13|Roman to Integer|[Python](python/013 Roman to Integer.py) [Java]()|Easy|| -|29|Divide Two Integers|[Python](python/029 Divide Two Integers.py) [Java]()|Medium|| -|43|Multiply Strings|[Python](python/043 Multiply Strings.py) [Java]()|Medium|| -|50|Pow(x, n)|[Python](python/050 Pow(x, n).py) [Java]()|Medium|| -|60|Permutation Sequence|[Python](python/060 Permutation Sequence.py) [Java]()|Medium|| -|65|Valid Number|[Python](python/065 Valid Number.py) [Java]()|Hard|| -|66|Plus One|[Python](python/066 Plus One.py) [Java]()|Easy|| -|67|Add Binary|[Python](python/067 Add Binary.py) [Java]()|Easy|| -|69|Sqrt(x)|[Python](python/069 Sqrt(x).py) [Java]()|Easy|| -|149|Max Points on a Line|[Python](python/149 Max Points on a Line.py) [Java]()|Hard|| -|166|Fraction to Recurring Decimal|[Python](python/166 Fraction to Recurring Decimal.py) [Java]()|Medium|| -|168|Excel Sheet Column Title|[Python](python/168 Excel Sheet Column Title.py) [Java]()|Easy|| -|171|Excel Sheet Column Number|[Python](python/171 Excel Sheet Column Number.py) [Java]()|Easy|| -|172|Factorial Trailing Zeroes|[Python](python/172 Factorial Trailing Zeroes.py) [Java]()|Easy|| -|202|Happy Number|[Python](python/202 Happy Number.py) [Java]()|Easy|| -|204|Count Primes|[Python](python/204 Count Primes.py) [Java]()|Easy|| -|223|Rectangle Area|[Python](python/223 Rectangle Area.py) [Java]()|Medium|| -|224|Basic Calculator|[Python](python/224 Basic Calculator.py) [Java]()|Hard|| -|231|Power of Two|[Python](python/231 Power of Two.py) [Java]()|Easy|| -|233|Number of Digit One|[Python](python/233 Number of Digit One.py) [Java]()|Hard|| -|246|Strobogrammatic Number|[Python](python/246 Strobogrammatic Number.py) [Java]()|Easy|| -|247|Strobogrammatic Number II|[Python](python/247 Strobogrammatic Number II.py) [Java]()|Medium|| -|248|Strobogrammatic Number III|[Python](python/248 Strobogrammatic Number III.py) [Java]()|Hard|| -|258|Add Digits|[Python](python/258 Add Digits.py) [Java]()|Easy|| -|263|Ugly Number|[Python](python/263 Ugly Number.py) [Java]()|Easy|| -|264|Ugly Number II|[Python](python/264 Ugly Number II.py) [Java]()|Medium|| -|268|Missing Number|[Python](python/268 Missing Number.py) [Java]()|Easy|| -|273|Integer to English Words|[Python](python/273 Integer to English Words.py) [Java]()|Hard|| -|279|Perfect Squares|[Python](python/279 Perfect Squares.py) [Java]()|Medium|| -|296|Best Meeting Point|[Python](python/296 Best Meeting Point.py) [Java]()|Hard|| -|313|Super Ugly Number|[Python](python/313 Super Ugly Number.py) [Java]()|Medium|| -|319|Bulb Switcher|[Python](python/319 Bulb Switcher.py) [Java]()|Medium|| -|326|Power of Three|[Python](python/326 Power of Three.py) [Java]()|Easy|| -|335|Self Crossing|[Python](python/335 Self Crossing.py) [Java]()|Hard|| -|343|Integer Break|[Python](python/343 Integer Break.py) [Java]()|Medium|| -|356|Line Reflection|[Python](python/356 Line Reflection.py) [Java]()|Medium|| -|357|Count Numbers with Unique Digits|[Python](python/357 Count Numbers with Unique Digits.py) [Java]()|Medium|| -|360|Sort Transformed Array|[Python](python/360 Sort Transformed Array.py) [Java]()|Medium|| -|365|Water and Jug Problem|[Python](python/365 Water and Jug Problem.py) [Java]()|Medium|| -|367|Valid Perfect Square|[Python](python/367 Valid Perfect Square.py) [Java]()|Easy|| -|368|Largest Divisible Subset|[Python](python/368 Largest Divisible Subset.py) [Java]()|Medium|| -|372|Super Pow|[Python](python/372 Super Pow.py) [Java]()|Medium|| -|396|Rotate Function|[Python](python/396 Rotate Function.py) [Java]()|Medium|| -|397|Integer Replacement|[Python](python/397 Integer Replacement.py) [Java]()|Medium|| -|400|Nth Digit|[Python](python/400 Nth Digit.py) [Java]()|Easy|| -|413|Arithmetic Slices|[Python](python/413 Arithmetic Slices.py) [Java]()|Medium|| -|415|Add Strings|[Python](python/415 Add Strings.py) [Java]()|Easy|| -|423|Reconstruct Original Digits from English|[Python](python/423 Reconstruct Original Digits from English.py) [Java]()|Medium|| -|441|Arranging Coins|[Python](python/441 Arranging Coins.py) [Java]()|Easy|| -|453|Minimum Moves to Equal Array Elements|[Python](python/453 Minimum Moves to Equal Array Elements.py) [Java]()|Easy|| -|462|Minimum Moves to Equal Array Elements II|[Python](python/462 Minimum Moves to Equal Array Elements II.py) [Java]()|Medium|| -|469|Convex Polygon|[Python](python/469 Convex Polygon.py) [Java]()|Medium|| -|483|Smallest Good Base|[Python](python/483 Smallest Good Base.py) [Java]()|Hard|| -|507|Perfect Number|[Python](python/507 Perfect Number.py) [Java]()|Easy|| -|517|Super Washing Machines|[Python](python/517 Super Washing Machines.py) [Java]()|Hard|| -|523|Continuous Subarray Sum|[Python](python/523 Continuous Subarray Sum.py) [Java]()|Medium|| -|535|Encode and Decode TinyURL|[Python](python/535 Encode and Decode TinyURL.py) [Java]()|Medium|| -|537|Complex Number Multiplication|[Python](python/537 Complex Number Multiplication.py) [Java]()|Medium|| -|553|Optimal Division|[Python](python/553 Optimal Division.py) [Java]()|Medium|| +|2|[Add Two Numbers](https://leetcode.com/problems/add-two-numbers)|[Python](./python/002 Add Two Numbers.py) [Java]()|Medium|| +|7|[Reverse Integer](https://leetcode.com/problems/reverse-integer)|[Python](./python/007 Reverse Integer.py) [Java]()|Easy|| +|8|[String to Integer (atoi)](https://leetcode.com/problems/string-to-integer-(atoi))|[Python](./python/008 String to Integer (atoi).py) [Java]()|Medium|| +|9|[Palindrome Number](https://leetcode.com/problems/palindrome-number)|[Python](./python/009 Palindrome Number.py) [Java]()|Easy|| +|12|[Integer to Roman](https://leetcode.com/problems/integer-to-roman)|[Python](./python/012 Integer to Roman.py) [Java]()|Medium|| +|13|[Roman to Integer](https://leetcode.com/problems/roman-to-integer)|[Python](./python/013 Roman to Integer.py) [Java]()|Easy|| +|29|[Divide Two Integers](https://leetcode.com/problems/divide-two-integers)|[Python](./python/029 Divide Two Integers.py) [Java]()|Medium|| +|43|[Multiply Strings](https://leetcode.com/problems/multiply-strings)|[Python](./python/043 Multiply Strings.py) [Java]()|Medium|| +|50|[Pow(x, n)](https://leetcode.com/problems/pow(x,-n))|[Python](./python/050 Pow(x, n).py) [Java]()|Medium|| +|60|[Permutation Sequence](https://leetcode.com/problems/permutation-sequence)|[Python](./python/060 Permutation Sequence.py) [Java]()|Medium|| +|65|[Valid Number](https://leetcode.com/problems/valid-number)|[Python](./python/065 Valid Number.py) [Java]()|Hard|| +|66|[Plus One](https://leetcode.com/problems/plus-one)|[Python](./python/066 Plus One.py) [Java]()|Easy|| +|67|[Add Binary](https://leetcode.com/problems/add-binary)|[Python](./python/067 Add Binary.py) [Java]()|Easy|| +|69|[Sqrt(x)](https://leetcode.com/problems/sqrt(x))|[Python](./python/069 Sqrt(x).py) [Java]()|Easy|| +|149|[Max Points on a Line](https://leetcode.com/problems/max-points-on-a-line)|[Python](./python/149 Max Points on a Line.py) [Java]()|Hard|| +|166|[Fraction to Recurring Decimal](https://leetcode.com/problems/fraction-to-recurring-decimal)|[Python](./python/166 Fraction to Recurring Decimal.py) [Java]()|Medium|| +|168|[Excel Sheet Column Title](https://leetcode.com/problems/excel-sheet-column-title)|[Python](./python/168 Excel Sheet Column Title.py) [Java]()|Easy|| +|171|[Excel Sheet Column Number](https://leetcode.com/problems/excel-sheet-column-number)|[Python](./python/171 Excel Sheet Column Number.py) [Java]()|Easy|| +|172|[Factorial Trailing Zeroes](https://leetcode.com/problems/factorial-trailing-zeroes)|[Python](./python/172 Factorial Trailing Zeroes.py) [Java]()|Easy|| +|202|[Happy Number](https://leetcode.com/problems/happy-number)|[Python](./python/202 Happy Number.py) [Java]()|Easy|| +|204|[Count Primes](https://leetcode.com/problems/count-primes)|[Python](./python/204 Count Primes.py) [Java]()|Easy|| +|223|[Rectangle Area](https://leetcode.com/problems/rectangle-area)|[Python](./python/223 Rectangle Area.py) [Java]()|Medium|| +|224|[Basic Calculator](https://leetcode.com/problems/basic-calculator)|[Python](./python/224 Basic Calculator.py) [Java]()|Hard|| +|231|[Power of Two](https://leetcode.com/problems/power-of-two)|[Python](./python/231 Power of Two.py) [Java]()|Easy|| +|233|[Number of Digit One](https://leetcode.com/problems/number-of-digit-one)|[Python](./python/233 Number of Digit One.py) [Java]()|Hard|| +|246|[Strobogrammatic Number](https://leetcode.com/problems/strobogrammatic-number)|[Python](./python/246 Strobogrammatic Number.py) [Java]()|Easy|| +|247|[Strobogrammatic Number II](https://leetcode.com/problems/strobogrammatic-number-ii)|[Python](./python/247 Strobogrammatic Number II.py) [Java]()|Medium|| +|248|[Strobogrammatic Number III](https://leetcode.com/problems/strobogrammatic-number-iii)|[Python](./python/248 Strobogrammatic Number III.py) [Java]()|Hard|| +|258|[Add Digits](https://leetcode.com/problems/add-digits)|[Python](./python/258 Add Digits.py) [Java]()|Easy|| +|263|[Ugly Number](https://leetcode.com/problems/ugly-number)|[Python](./python/263 Ugly Number.py) [Java]()|Easy|| +|264|[Ugly Number II](https://leetcode.com/problems/ugly-number-ii)|[Python](./python/264 Ugly Number II.py) [Java]()|Medium|| +|268|[Missing Number](https://leetcode.com/problems/missing-number)|[Python](./python/268 Missing Number.py) [Java]()|Easy|| +|273|[Integer to English Words](https://leetcode.com/problems/integer-to-english-words)|[Python](./python/273 Integer to English Words.py) [Java]()|Hard|| +|279|[Perfect Squares](https://leetcode.com/problems/perfect-squares)|[Python](./python/279 Perfect Squares.py) [Java]()|Medium|| +|296|[Best Meeting Point](https://leetcode.com/problems/best-meeting-point)|[Python](./python/296 Best Meeting Point.py) [Java]()|Hard|| +|313|[Super Ugly Number](https://leetcode.com/problems/super-ugly-number)|[Python](./python/313 Super Ugly Number.py) [Java]()|Medium|| +|319|[Bulb Switcher](https://leetcode.com/problems/bulb-switcher)|[Python](./python/319 Bulb Switcher.py) [Java]()|Medium|| +|326|[Power of Three](https://leetcode.com/problems/power-of-three)|[Python](./python/326 Power of Three.py) [Java]()|Easy|| +|335|[Self Crossing](https://leetcode.com/problems/self-crossing)|[Python](./python/335 Self Crossing.py) [Java]()|Hard|| +|343|[Integer Break](https://leetcode.com/problems/integer-break)|[Python](./python/343 Integer Break.py) [Java]()|Medium|| +|356|[Line Reflection](https://leetcode.com/problems/line-reflection)|[Python](./python/356 Line Reflection.py) [Java]()|Medium|| +|357|[Count Numbers with Unique Digits](https://leetcode.com/problems/count-numbers-with-unique-digits)|[Python](./python/357 Count Numbers with Unique Digits.py) [Java]()|Medium|| +|360|[Sort Transformed Array](https://leetcode.com/problems/sort-transformed-array)|[Python](./python/360 Sort Transformed Array.py) [Java]()|Medium|| +|365|[Water and Jug Problem](https://leetcode.com/problems/water-and-jug-problem)|[Python](./python/365 Water and Jug Problem.py) [Java]()|Medium|| +|367|[Valid Perfect Square](https://leetcode.com/problems/valid-perfect-square)|[Python](./python/367 Valid Perfect Square.py) [Java]()|Easy|| +|368|[Largest Divisible Subset](https://leetcode.com/problems/largest-divisible-subset)|[Python](./python/368 Largest Divisible Subset.py) [Java]()|Medium|| +|372|[Super Pow](https://leetcode.com/problems/super-pow)|[Python](./python/372 Super Pow.py) [Java]()|Medium|| +|396|[Rotate Function](https://leetcode.com/problems/rotate-function)|[Python](./python/396 Rotate Function.py) [Java]()|Medium|| +|397|[Integer Replacement](https://leetcode.com/problems/integer-replacement)|[Python](./python/397 Integer Replacement.py) [Java]()|Medium|| +|400|[Nth Digit](https://leetcode.com/problems/nth-digit)|[Python](./python/400 Nth Digit.py) [Java]()|Easy|| +|413|[Arithmetic Slices](https://leetcode.com/problems/arithmetic-slices)|[Python](./python/413 Arithmetic Slices.py) [Java]()|Medium|| +|415|[Add Strings](https://leetcode.com/problems/add-strings)|[Python](./python/415 Add Strings.py) [Java]()|Easy|| +|423|[Reconstruct Original Digits from English](https://leetcode.com/problems/reconstruct-original-digits-from-english)|[Python](./python/423 Reconstruct Original Digits from English.py) [Java]()|Medium|| +|441|[Arranging Coins](https://leetcode.com/problems/arranging-coins)|[Python](./python/441 Arranging Coins.py) [Java]()|Easy|| +|453|[Minimum Moves to Equal Array Elements](https://leetcode.com/problems/minimum-moves-to-equal-array-elements)|[Python](./python/453 Minimum Moves to Equal Array Elements.py) [Java]()|Easy|| +|462|[Minimum Moves to Equal Array Elements II](https://leetcode.com/problems/minimum-moves-to-equal-array-elements-ii)|[Python](./python/462 Minimum Moves to Equal Array Elements II.py) [Java]()|Medium|| +|469|[Convex Polygon](https://leetcode.com/problems/convex-polygon)|[Python](./python/469 Convex Polygon.py) [Java]()|Medium|| +|483|[Smallest Good Base](https://leetcode.com/problems/smallest-good-base)|[Python](./python/483 Smallest Good Base.py) [Java]()|Hard|| +|507|[Perfect Number](https://leetcode.com/problems/perfect-number)|[Python](./python/507 Perfect Number.py) [Java]()|Easy|| +|517|[Super Washing Machines](https://leetcode.com/problems/super-washing-machines)|[Python](./python/517 Super Washing Machines.py) [Java]()|Hard|| +|523|[Continuous Subarray Sum](https://leetcode.com/problems/continuous-subarray-sum)|[Python](./python/523 Continuous Subarray Sum.py) [Java]()|Medium|| +|535|[Encode and Decode TinyURL](https://leetcode.com/problems/encode-and-decode-tinyurl)|[Python](./python/535 Encode and Decode TinyURL.py) [Java]()|Medium|| +|537|[Complex Number Multiplication](https://leetcode.com/problems/complex-number-multiplication)|[Python](./python/537 Complex Number Multiplication.py) [Java]()|Medium|| +|553|[Optimal Division](https://leetcode.com/problems/optimal-division)|[Python](./python/553 Optimal Division.py) [Java]()|Medium|| ## Two Pointers | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|3|Longest Substring Without Repeating Characters|[Python](python/003 Longest Substring Without Repeating Characters.py) [Java]()|Medium|| -|11|Container With Most Water|[Python](python/011 Container With Most Water.py) [Java]()|Medium|| -|15|3Sum|[Python](python/015 3Sum.py) [Java]()|Medium|| -|16|3Sum Closest|[Python](python/016 3Sum Closest.py) [Java]()|Medium|| -|18|4Sum|[Python](python/018 4Sum.py) [Java]()|Medium|| -|19|Remove Nth Node From End of List|[Python](python/019 Remove Nth Node From End of List.py) [Java]()|Medium|| -|26|Remove Duplicates from Sorted Array|[Python](python/026 Remove Duplicates from Sorted Array.py) [Java]()|Easy|| -|27|Remove Element|[Python](python/027 Remove Element.py) [Java]()|Easy|| -|28|Implement strStr()|[Python](python/028 Implement strStr().py) [Java]()|Easy|| -|30|Substring with Concatenation of All Words|[Python](python/030 Substring with Concatenation of All Words.py) [Java]()|Hard|| -|42|Trapping Rain Water|[Python](python/042 Trapping Rain Water.py) [Java]()|Hard|| -|61|Rotate List|[Python](python/061 Rotate List.py) [Java]()|Medium|| -|75|Sort Colors|[Python](python/075 Sort Colors.py) [Java]()|Medium|| -|76|Minimum Window Substring|[Python](python/076 Minimum Window Substring.py) [Java]()|Hard|| -|80|Remove Duplicates from Sorted Array II|[Python](python/080 Remove Duplicates from Sorted Array II.py) [Java]()|Medium|| -|86|Partition List|[Python](python/086 Partition List.py) [Java]()|Medium|| -|88|Merge Sorted Array|[Python](python/088 Merge Sorted Array.py) [Java]()|Easy|| -|125|Valid Palindrome|[Python](python/125 Valid Palindrome.py) [Java]()|Easy|| -|141|Linked List Cycle|[Python](python/141 Linked List Cycle.py) [Java]()|Easy|| -|142|Linked List Cycle II|[Python](python/142 Linked List Cycle II.py) [Java]()|Medium|| -|159|Longest Substring with At Most Two Distinct Characters|[Python](python/159 Longest Substring with At Most Two Distinct Characters.py) [Java]()|Hard|| -|167|Two Sum II - Input array is sorted|[Python](python/167 Two Sum II - Input array is sorted.py) [Java]()|Easy|| -|209|Minimum Size Subarray Sum|[Python](python/209 Minimum Size Subarray Sum.py) [Java]()|Medium|| -|234|Palindrome Linked List|[Python](python/234 Palindrome Linked List.py) [Java]()|Easy|| -|259|3Sum Smaller|[Python](python/259 3Sum Smaller.py) [Java]()|Medium|| -|283|Move Zeroes|[Python](python/283 Move Zeroes.py) [Java]()|Easy|| -|287|Find the Duplicate Number|[Python](python/287 Find the Duplicate Number.py) [Java]()|Medium|| -|344|Reverse String|[Python](python/344 Reverse String.py) [Java]()|Easy|| -|345|Reverse Vowels of a String|[Python](python/345 Reverse Vowels of a String.py) [Java]()|Easy|| -|349|Intersection of Two Arrays|[Python](python/349 Intersection of Two Arrays.py) [Java]()|Easy|| -|350|Intersection of Two Arrays II|[Python](python/350 Intersection of Two Arrays II.py) [Java]()|Easy|| -|360|Sort Transformed Array|[Python](python/360 Sort Transformed Array.py) [Java]()|Medium|| -|487|Max Consecutive Ones II|[Python](python/487 Max Consecutive Ones II.py) [Java]()|Medium|| -|524|Longest Word in Dictionary through Deleting|[Python](python/524 Longest Word in Dictionary through Deleting.py) [Java]()|Medium|| -|532|K-diff Pairs in an Array|[Python](python/532 K-diff Pairs in an Array.py) [Java]()|Easy|| -|567|Permutation in String|[Python](python/567 Permutation in String.py) [Java]()|Medium|| +|3|[Longest Substring Without Repeating Characters](https://leetcode.com/problems/longest-substring-without-repeating-characters)|[Python](./python/003 Longest Substring Without Repeating Characters.py) [Java]()|Medium|| +|11|[Container With Most Water](https://leetcode.com/problems/container-with-most-water)|[Python](./python/011 Container With Most Water.py) [Java]()|Medium|| +|15|[3Sum](https://leetcode.com/problems/3sum)|[Python](./python/015 3Sum.py) [Java]()|Medium|| +|16|[3Sum Closest](https://leetcode.com/problems/3sum-closest)|[Python](./python/016 3Sum Closest.py) [Java]()|Medium|| +|18|[4Sum](https://leetcode.com/problems/4sum)|[Python](./python/018 4Sum.py) [Java]()|Medium|| +|19|[Remove Nth Node From End of List](https://leetcode.com/problems/remove-nth-node-from-end-of-list)|[Python](./python/019 Remove Nth Node From End of List.py) [Java]()|Medium|| +|26|[Remove Duplicates from Sorted Array](https://leetcode.com/problems/remove-duplicates-from-sorted-array)|[Python](./python/026 Remove Duplicates from Sorted Array.py) [Java]()|Easy|| +|27|[Remove Element](https://leetcode.com/problems/remove-element)|[Python](./python/027 Remove Element.py) [Java]()|Easy|| +|28|[Implement strStr()](https://leetcode.com/problems/implement-strstr())|[Python](./python/028 Implement strStr().py) [Java]()|Easy|| +|30|[Substring with Concatenation of All Words](https://leetcode.com/problems/substring-with-concatenation-of-all-words)|[Python](./python/030 Substring with Concatenation of All Words.py) [Java]()|Hard|| +|42|[Trapping Rain Water](https://leetcode.com/problems/trapping-rain-water)|[Python](./python/042 Trapping Rain Water.py) [Java]()|Hard|| +|61|[Rotate List](https://leetcode.com/problems/rotate-list)|[Python](./python/061 Rotate List.py) [Java]()|Medium|| +|75|[Sort Colors](https://leetcode.com/problems/sort-colors)|[Python](./python/075 Sort Colors.py) [Java]()|Medium|| +|76|[Minimum Window Substring](https://leetcode.com/problems/minimum-window-substring)|[Python](./python/076 Minimum Window Substring.py) [Java]()|Hard|| +|80|[Remove Duplicates from Sorted Array II](https://leetcode.com/problems/remove-duplicates-from-sorted-array-ii)|[Python](./python/080 Remove Duplicates from Sorted Array II.py) [Java]()|Medium|| +|86|[Partition List](https://leetcode.com/problems/partition-list)|[Python](./python/086 Partition List.py) [Java]()|Medium|| +|88|[Merge Sorted Array](https://leetcode.com/problems/merge-sorted-array)|[Python](./python/088 Merge Sorted Array.py) [Java]()|Easy|| +|125|[Valid Palindrome](https://leetcode.com/problems/valid-palindrome)|[Python](./python/125 Valid Palindrome.py) [Java]()|Easy|| +|141|[Linked List Cycle](https://leetcode.com/problems/linked-list-cycle)|[Python](./python/141 Linked List Cycle.py) [Java]()|Easy|| +|142|[Linked List Cycle II](https://leetcode.com/problems/linked-list-cycle-ii)|[Python](./python/142 Linked List Cycle II.py) [Java]()|Medium|| +|159|[Longest Substring with At Most Two Distinct Characters](https://leetcode.com/problems/longest-substring-with-at-most-two-distinct-characters)|[Python](./python/159 Longest Substring with At Most Two Distinct Characters.py) [Java]()|Hard|| +|167|[Two Sum II - Input array is sorted](https://leetcode.com/problems/two-sum-ii---input-array-is-sorted)|[Python](./python/167 Two Sum II - Input array is sorted.py) [Java]()|Easy|| +|209|[Minimum Size Subarray Sum](https://leetcode.com/problems/minimum-size-subarray-sum)|[Python](./python/209 Minimum Size Subarray Sum.py) [Java]()|Medium|| +|234|[Palindrome Linked List](https://leetcode.com/problems/palindrome-linked-list)|[Python](./python/234 Palindrome Linked List.py) [Java]()|Easy|| +|259|[3Sum Smaller](https://leetcode.com/problems/3sum-smaller)|[Python](./python/259 3Sum Smaller.py) [Java]()|Medium|| +|283|[Move Zeroes](https://leetcode.com/problems/move-zeroes)|[Python](./python/283 Move Zeroes.py) [Java]()|Easy|| +|287|[Find the Duplicate Number](https://leetcode.com/problems/find-the-duplicate-number)|[Python](./python/287 Find the Duplicate Number.py) [Java]()|Medium|| +|344|[Reverse String](https://leetcode.com/problems/reverse-string)|[Python](./python/344 Reverse String.py) [Java]()|Easy|| +|345|[Reverse Vowels of a String](https://leetcode.com/problems/reverse-vowels-of-a-string)|[Python](./python/345 Reverse Vowels of a String.py) [Java]()|Easy|| +|349|[Intersection of Two Arrays](https://leetcode.com/problems/intersection-of-two-arrays)|[Python](./python/349 Intersection of Two Arrays.py) [Java]()|Easy|| +|350|[Intersection of Two Arrays II](https://leetcode.com/problems/intersection-of-two-arrays-ii)|[Python](./python/350 Intersection of Two Arrays II.py) [Java]()|Easy|| +|360|[Sort Transformed Array](https://leetcode.com/problems/sort-transformed-array)|[Python](./python/360 Sort Transformed Array.py) [Java]()|Medium|| +|487|[Max Consecutive Ones II](https://leetcode.com/problems/max-consecutive-ones-ii)|[Python](./python/487 Max Consecutive Ones II.py) [Java]()|Medium|| +|524|[Longest Word in Dictionary through Deleting](https://leetcode.com/problems/longest-word-in-dictionary-through-deleting)|[Python](./python/524 Longest Word in Dictionary through Deleting.py) [Java]()|Medium|| +|532|[K-diff Pairs in an Array](https://leetcode.com/problems/k-diff-pairs-in-an-array)|[Python](./python/532 K-diff Pairs in an Array.py) [Java]()|Easy|| +|567|[Permutation in String](https://leetcode.com/problems/permutation-in-string)|[Python](./python/567 Permutation in String.py) [Java]()|Medium|| ## String | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|3|Longest Substring Without Repeating Characters|[Python](python/003 Longest Substring Without Repeating Characters.py) [Java]()|Medium|| -|5|Longest Palindromic Substring|[Python](python/005 Longest Palindromic Substring.py) [Java]()|Medium|| -|6|ZigZag Conversion|[Python](python/006 ZigZag Conversion.py) [Java]()|Medium|| -|8|String to Integer (atoi)|[Python](python/008 String to Integer (atoi).py) [Java]()|Medium|| -|10|Regular Expression Matching|[Python](python/010 Regular Expression Matching.py) [Java]()|Hard|| -|12|Integer to Roman|[Python](python/012 Integer to Roman.py) [Java]()|Medium|| -|13|Roman to Integer|[Python](python/013 Roman to Integer.py) [Java]()|Easy|| -|14|Longest Common Prefix|[Python](python/014 Longest Common Prefix.py) [Java]()|Easy|| -|17|Letter Combinations of a Phone Number|[Python](python/017 Letter Combinations of a Phone Number.py) [Java]()|Medium|| -|20|Valid Parentheses|[Python](python/020 Valid Parentheses.py) [Java]()|Easy|| -|22|Generate Parentheses|[Python](python/022 Generate Parentheses.py) [Java]()|Medium|| -|28|Implement strStr()|[Python](python/028 Implement strStr().py) [Java]()|Easy|| -|30|Substring with Concatenation of All Words|[Python](python/030 Substring with Concatenation of All Words.py) [Java]()|Hard|| -|32|Longest Valid Parentheses|[Python](python/032 Longest Valid Parentheses.py) [Java]()|Hard|| -|38|Count and Say|[Python](python/038 Count and Say.py) [Java]()|Easy|| -|43|Multiply Strings|[Python](python/043 Multiply Strings.py) [Java]()|Medium|| -|44|Wildcard Matching|[Python](python/044 Wildcard Matching.py) [Java]()|Hard|| -|49|Group Anagrams|[Python](python/049 Group Anagrams.py) [Java]()|Medium|| -|58|Length of Last Word|[Python](python/058 Length of Last Word.py) [Java]()|Easy|| -|65|Valid Number|[Python](python/065 Valid Number.py) [Java]()|Hard|| -|67|Add Binary|[Python](python/067 Add Binary.py) [Java]()|Easy|| -|68|Text Justification|[Python](python/068 Text Justification.py) [Java]()|Hard|| -|71|Simplify Path|[Python](python/071 Simplify Path.py) [Java]()|Medium|| -|72|Edit Distance|[Python](python/072 Edit Distance.py) [Java]()|Hard|| -|76|Minimum Window Substring|[Python](python/076 Minimum Window Substring.py) [Java]()|Hard|| -|87|Scramble String|[Python](python/087 Scramble String.py) [Java]()|Hard|| -|91|Decode Ways|[Python](python/091 Decode Ways.py) [Java]()|Medium|| -|93|Restore IP Addresses|[Python](python/093 Restore IP Addresses.py) [Java]()|Medium|| -|97|Interleaving String|[Python](python/097 Interleaving String.py) [Java]()|Hard|| -|115|Distinct Subsequences|[Python](python/115 Distinct Subsequences.py) [Java]()|Hard|| -|125|Valid Palindrome|[Python](python/125 Valid Palindrome.py) [Java]()|Easy|| -|126|Word Ladder II|[Python](python/126 Word Ladder II.py) [Java]()|Hard|| -|151|Reverse Words in a String|[Python](python/151 Reverse Words in a String.py) [Java]()|Medium|| -|157|Read N Characters Given Read4|[Python](python/157 Read N Characters Given Read4.py) [Java]()|Easy|| -|158|Read N Characters Given Read4 II - Call multiple times|[Python](python/158 Read N Characters Given Read4 II - Call multiple times.py) [Java]()|Hard|| -|159|Longest Substring with At Most Two Distinct Characters|[Python](python/159 Longest Substring with At Most Two Distinct Characters.py) [Java]()|Hard|| -|161|One Edit Distance|[Python](python/161 One Edit Distance.py) [Java]()|Medium|| -|165|Compare Version Numbers|[Python](python/165 Compare Version Numbers.py) [Java]()|Medium|| -|186|Reverse Words in a String II|[Python](python/186 Reverse Words in a String II.py) [Java]()|Medium|| -|214|Shortest Palindrome|[Python](python/214 Shortest Palindrome.py) [Java]()|Hard|| -|227|Basic Calculator II|[Python](python/227 Basic Calculator II.py) [Java]()|Medium|| -|249|Group Shifted Strings|[Python](python/249 Group Shifted Strings.py) [Java]()|Medium|| -|271|Encode and Decode Strings|[Python](python/271 Encode and Decode Strings.py) [Java]()|Medium|| -|273|Integer to English Words|[Python](python/273 Integer to English Words.py) [Java]()|Hard|| -|293|Flip Game|[Python](python/293 Flip Game.py) [Java]()|Easy|| -|336|Palindrome Pairs|[Python](python/336 Palindrome Pairs.py) [Java]()|Hard|| -|340|Longest Substring with At Most K Distinct Characters|[Python](python/340 Longest Substring with At Most K Distinct Characters.py) [Java]()|Hard|| -|344|Reverse String|[Python](python/344 Reverse String.py) [Java]()|Easy|| -|345|Reverse Vowels of a String|[Python](python/345 Reverse Vowels of a String.py) [Java]()|Easy|| -|383|Ransom Note|[Python](python/383 Ransom Note.py) [Java]()|Easy|| -|385|Mini Parser|[Python](python/385 Mini Parser.py) [Java]()|Medium|| -|408|Valid Word Abbreviation|[Python](python/408 Valid Word Abbreviation.py) [Java]()|Easy|| -|434|Number of Segments in a String|[Python](python/434 Number of Segments in a String.py) [Java]()|Easy|| -|459|Repeated Substring Pattern|[Python](python/459 Repeated Substring Pattern.py) [Java]()|Easy|| -|468|Validate IP Address|[Python](python/468 Validate IP Address.py) [Java]()|Medium|| -|520|Detect Capital|[Python](python/520 Detect Capital.py) [Java]()|Easy|| -|521|Longest Uncommon Subsequence I|[Python](python/521 Longest Uncommon Subsequence I.py) [Java]()|Easy|| -|522|Longest Uncommon Subsequence II|[Python](python/522 Longest Uncommon Subsequence II.py) [Java]()|Medium|| -|527|Word Abbreviation|[Python](python/527 Word Abbreviation.py) [Java]()|Hard|| -|536|Construct Binary Tree from String|[Python](python/536 Construct Binary Tree from String.py) [Java]()|Medium|| -|537|Complex Number Multiplication|[Python](python/537 Complex Number Multiplication.py) [Java]()|Medium|| -|539|Minimum Time Difference|[Python](python/539 Minimum Time Difference.py) [Java]()|Medium|| -|541|Reverse String II|[Python](python/541 Reverse String II.py) [Java]()|Easy|| -|544|Output Contest Matches|[Python](python/544 Output Contest Matches.py) [Java]()|Medium|| -|551|Student Attendance Record I|[Python](python/551 Student Attendance Record I.py) [Java]()|Easy|| -|553|Optimal Division|[Python](python/553 Optimal Division.py) [Java]()|Medium|| -|555|Split Concatenated Strings|[Python](python/555 Split Concatenated Strings.py) [Java]()|Medium|| -|556|Next Greater Element III|[Python](python/556 Next Greater Element III.py) [Java]()|Medium|| -|557|Reverse Words in a String III|[Python](python/557 Reverse Words in a String III.py) [Java]()|Easy|| -|564|Find the Closest Palindrome|[Python](python/564 Find the Closest Palindrome.py) [Java]()|Hard|| +|3|[Longest Substring Without Repeating Characters](https://leetcode.com/problems/longest-substring-without-repeating-characters)|[Python](./python/003 Longest Substring Without Repeating Characters.py) [Java]()|Medium|| +|5|[Longest Palindromic Substring](https://leetcode.com/problems/longest-palindromic-substring)|[Python](./python/005 Longest Palindromic Substring.py) [Java]()|Medium|| +|6|[ZigZag Conversion](https://leetcode.com/problems/zigzag-conversion)|[Python](./python/006 ZigZag Conversion.py) [Java]()|Medium|| +|8|[String to Integer (atoi)](https://leetcode.com/problems/string-to-integer-(atoi))|[Python](./python/008 String to Integer (atoi).py) [Java]()|Medium|| +|10|[Regular Expression Matching](https://leetcode.com/problems/regular-expression-matching)|[Python](./python/010 Regular Expression Matching.py) [Java]()|Hard|| +|12|[Integer to Roman](https://leetcode.com/problems/integer-to-roman)|[Python](./python/012 Integer to Roman.py) [Java]()|Medium|| +|13|[Roman to Integer](https://leetcode.com/problems/roman-to-integer)|[Python](./python/013 Roman to Integer.py) [Java]()|Easy|| +|14|[Longest Common Prefix](https://leetcode.com/problems/longest-common-prefix)|[Python](./python/014 Longest Common Prefix.py) [Java]()|Easy|| +|17|[Letter Combinations of a Phone Number](https://leetcode.com/problems/letter-combinations-of-a-phone-number)|[Python](./python/017 Letter Combinations of a Phone Number.py) [Java]()|Medium|| +|20|[Valid Parentheses](https://leetcode.com/problems/valid-parentheses)|[Python](./python/020 Valid Parentheses.py) [Java]()|Easy|| +|22|[Generate Parentheses](https://leetcode.com/problems/generate-parentheses)|[Python](./python/022 Generate Parentheses.py) [Java]()|Medium|| +|28|[Implement strStr()](https://leetcode.com/problems/implement-strstr())|[Python](./python/028 Implement strStr().py) [Java]()|Easy|| +|30|[Substring with Concatenation of All Words](https://leetcode.com/problems/substring-with-concatenation-of-all-words)|[Python](./python/030 Substring with Concatenation of All Words.py) [Java]()|Hard|| +|32|[Longest Valid Parentheses](https://leetcode.com/problems/longest-valid-parentheses)|[Python](./python/032 Longest Valid Parentheses.py) [Java]()|Hard|| +|38|[Count and Say](https://leetcode.com/problems/count-and-say)|[Python](./python/038 Count and Say.py) [Java]()|Easy|| +|43|[Multiply Strings](https://leetcode.com/problems/multiply-strings)|[Python](./python/043 Multiply Strings.py) [Java]()|Medium|| +|44|[Wildcard Matching](https://leetcode.com/problems/wildcard-matching)|[Python](./python/044 Wildcard Matching.py) [Java]()|Hard|| +|49|[Group Anagrams](https://leetcode.com/problems/group-anagrams)|[Python](./python/049 Group Anagrams.py) [Java]()|Medium|| +|58|[Length of Last Word](https://leetcode.com/problems/length-of-last-word)|[Python](./python/058 Length of Last Word.py) [Java]()|Easy|| +|65|[Valid Number](https://leetcode.com/problems/valid-number)|[Python](./python/065 Valid Number.py) [Java]()|Hard|| +|67|[Add Binary](https://leetcode.com/problems/add-binary)|[Python](./python/067 Add Binary.py) [Java]()|Easy|| +|68|[Text Justification](https://leetcode.com/problems/text-justification)|[Python](./python/068 Text Justification.py) [Java]()|Hard|| +|71|[Simplify Path](https://leetcode.com/problems/simplify-path)|[Python](./python/071 Simplify Path.py) [Java]()|Medium|| +|72|[Edit Distance](https://leetcode.com/problems/edit-distance)|[Python](./python/072 Edit Distance.py) [Java]()|Hard|| +|76|[Minimum Window Substring](https://leetcode.com/problems/minimum-window-substring)|[Python](./python/076 Minimum Window Substring.py) [Java]()|Hard|| +|87|[Scramble String](https://leetcode.com/problems/scramble-string)|[Python](./python/087 Scramble String.py) [Java]()|Hard|| +|91|[Decode Ways](https://leetcode.com/problems/decode-ways)|[Python](./python/091 Decode Ways.py) [Java]()|Medium|| +|93|[Restore IP Addresses](https://leetcode.com/problems/restore-ip-addresses)|[Python](./python/093 Restore IP Addresses.py) [Java]()|Medium|| +|97|[Interleaving String](https://leetcode.com/problems/interleaving-string)|[Python](./python/097 Interleaving String.py) [Java]()|Hard|| +|115|[Distinct Subsequences](https://leetcode.com/problems/distinct-subsequences)|[Python](./python/115 Distinct Subsequences.py) [Java]()|Hard|| +|125|[Valid Palindrome](https://leetcode.com/problems/valid-palindrome)|[Python](./python/125 Valid Palindrome.py) [Java]()|Easy|| +|126|[Word Ladder II](https://leetcode.com/problems/word-ladder-ii)|[Python](./python/126 Word Ladder II.py) [Java]()|Hard|| +|151|[Reverse Words in a String](https://leetcode.com/problems/reverse-words-in-a-string)|[Python](./python/151 Reverse Words in a String.py) [Java]()|Medium|| +|157|[Read N Characters Given Read4](https://leetcode.com/problems/read-n-characters-given-read4)|[Python](./python/157 Read N Characters Given Read4.py) [Java]()|Easy|| +|158|[Read N Characters Given Read4 II - Call multiple times](https://leetcode.com/problems/read-n-characters-given-read4-ii---call-multiple-times)|[Python](./python/158 Read N Characters Given Read4 II - Call multiple times.py) [Java]()|Hard|| +|159|[Longest Substring with At Most Two Distinct Characters](https://leetcode.com/problems/longest-substring-with-at-most-two-distinct-characters)|[Python](./python/159 Longest Substring with At Most Two Distinct Characters.py) [Java]()|Hard|| +|161|[One Edit Distance](https://leetcode.com/problems/one-edit-distance)|[Python](./python/161 One Edit Distance.py) [Java]()|Medium|| +|165|[Compare Version Numbers](https://leetcode.com/problems/compare-version-numbers)|[Python](./python/165 Compare Version Numbers.py) [Java]()|Medium|| +|186|[Reverse Words in a String II](https://leetcode.com/problems/reverse-words-in-a-string-ii)|[Python](./python/186 Reverse Words in a String II.py) [Java]()|Medium|| +|214|[Shortest Palindrome](https://leetcode.com/problems/shortest-palindrome)|[Python](./python/214 Shortest Palindrome.py) [Java]()|Hard|| +|227|[Basic Calculator II](https://leetcode.com/problems/basic-calculator-ii)|[Python](./python/227 Basic Calculator II.py) [Java]()|Medium|| +|249|[Group Shifted Strings](https://leetcode.com/problems/group-shifted-strings)|[Python](./python/249 Group Shifted Strings.py) [Java]()|Medium|| +|271|[Encode and Decode Strings](https://leetcode.com/problems/encode-and-decode-strings)|[Python](./python/271 Encode and Decode Strings.py) [Java]()|Medium|| +|273|[Integer to English Words](https://leetcode.com/problems/integer-to-english-words)|[Python](./python/273 Integer to English Words.py) [Java]()|Hard|| +|293|[Flip Game](https://leetcode.com/problems/flip-game)|[Python](./python/293 Flip Game.py) [Java]()|Easy|| +|336|[Palindrome Pairs](https://leetcode.com/problems/palindrome-pairs)|[Python](./python/336 Palindrome Pairs.py) [Java]()|Hard|| +|340|[Longest Substring with At Most K Distinct Characters](https://leetcode.com/problems/longest-substring-with-at-most-k-distinct-characters)|[Python](./python/340 Longest Substring with At Most K Distinct Characters.py) [Java]()|Hard|| +|344|[Reverse String](https://leetcode.com/problems/reverse-string)|[Python](./python/344 Reverse String.py) [Java]()|Easy|| +|345|[Reverse Vowels of a String](https://leetcode.com/problems/reverse-vowels-of-a-string)|[Python](./python/345 Reverse Vowels of a String.py) [Java]()|Easy|| +|383|[Ransom Note](https://leetcode.com/problems/ransom-note)|[Python](./python/383 Ransom Note.py) [Java]()|Easy|| +|385|[Mini Parser](https://leetcode.com/problems/mini-parser)|[Python](./python/385 Mini Parser.py) [Java]()|Medium|| +|408|[Valid Word Abbreviation](https://leetcode.com/problems/valid-word-abbreviation)|[Python](./python/408 Valid Word Abbreviation.py) [Java]()|Easy|| +|434|[Number of Segments in a String](https://leetcode.com/problems/number-of-segments-in-a-string)|[Python](./python/434 Number of Segments in a String.py) [Java]()|Easy|| +|459|[Repeated Substring Pattern](https://leetcode.com/problems/repeated-substring-pattern)|[Python](./python/459 Repeated Substring Pattern.py) [Java]()|Easy|| +|468|[Validate IP Address](https://leetcode.com/problems/validate-ip-address)|[Python](./python/468 Validate IP Address.py) [Java]()|Medium|| +|520|[Detect Capital](https://leetcode.com/problems/detect-capital)|[Python](./python/520 Detect Capital.py) [Java]()|Easy|| +|521|[Longest Uncommon Subsequence I](https://leetcode.com/problems/longest-uncommon-subsequence-i)|[Python](./python/521 Longest Uncommon Subsequence I.py) [Java]()|Easy|| +|522|[Longest Uncommon Subsequence II](https://leetcode.com/problems/longest-uncommon-subsequence-ii)|[Python](./python/522 Longest Uncommon Subsequence II.py) [Java]()|Medium|| +|527|[Word Abbreviation](https://leetcode.com/problems/word-abbreviation)|[Python](./python/527 Word Abbreviation.py) [Java]()|Hard|| +|536|[Construct Binary Tree from String](https://leetcode.com/problems/construct-binary-tree-from-string)|[Python](./python/536 Construct Binary Tree from String.py) [Java]()|Medium|| +|537|[Complex Number Multiplication](https://leetcode.com/problems/complex-number-multiplication)|[Python](./python/537 Complex Number Multiplication.py) [Java]()|Medium|| +|539|[Minimum Time Difference](https://leetcode.com/problems/minimum-time-difference)|[Python](./python/539 Minimum Time Difference.py) [Java]()|Medium|| +|541|[Reverse String II](https://leetcode.com/problems/reverse-string-ii)|[Python](./python/541 Reverse String II.py) [Java]()|Easy|| +|544|[Output Contest Matches](https://leetcode.com/problems/output-contest-matches)|[Python](./python/544 Output Contest Matches.py) [Java]()|Medium|| +|551|[Student Attendance Record I](https://leetcode.com/problems/student-attendance-record-i)|[Python](./python/551 Student Attendance Record I.py) [Java]()|Easy|| +|553|[Optimal Division](https://leetcode.com/problems/optimal-division)|[Python](./python/553 Optimal Division.py) [Java]()|Medium|| +|555|[Split Concatenated Strings](https://leetcode.com/problems/split-concatenated-strings)|[Python](./python/555 Split Concatenated Strings.py) [Java]()|Medium|| +|556|[Next Greater Element III](https://leetcode.com/problems/next-greater-element-iii)|[Python](./python/556 Next Greater Element III.py) [Java]()|Medium|| +|557|[Reverse Words in a String III](https://leetcode.com/problems/reverse-words-in-a-string-iii)|[Python](./python/557 Reverse Words in a String III.py) [Java]()|Easy|| +|564|[Find the Closest Palindrome](https://leetcode.com/problems/find-the-closest-palindrome)|[Python](./python/564 Find the Closest Palindrome.py) [Java]()|Hard|| ## Binary Search | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|4|Median of Two Sorted Arrays|[Python](python/004 Median of Two Sorted Arrays.py) [Java]()|Hard|| -|29|Divide Two Integers|[Python](python/029 Divide Two Integers.py) [Java]()|Medium|| -|33|Search in Rotated Sorted Array|[Python](python/033 Search in Rotated Sorted Array.py) [Java]()|Medium|| -|34|Search for a Range|[Python](python/034 Search for a Range.py) [Java]()|Medium|| -|35|Search Insert Position|[Python](python/035 Search Insert Position.py) [Java]()|Easy|| -|50|Pow(x, n)|[Python](python/050 Pow(x, n).py) [Java]()|Medium|| -|69|Sqrt(x)|[Python](python/069 Sqrt(x).py) [Java]()|Easy|| -|74|Search a 2D Matrix|[Python](python/074 Search a 2D Matrix.py) [Java]()|Medium|| -|81|Search in Rotated Sorted Array II|[Python](python/081 Search in Rotated Sorted Array II.py) [Java]()|Medium|| -|153|Find Minimum in Rotated Sorted Array|[Python](python/153 Find Minimum in Rotated Sorted Array.py) [Java]()|Medium|| -|154|Find Minimum in Rotated Sorted Array II|[Python](python/154 Find Minimum in Rotated Sorted Array II.py) [Java]()|Hard|| -|162|Find Peak Element|[Python](python/162 Find Peak Element.py) [Java]()|Medium|| -|167|Two Sum II - Input array is sorted|[Python](python/167 Two Sum II - Input array is sorted.py) [Java]()|Easy|| -|174|Dungeon Game|[Python](python/174 Dungeon Game.py) [Java]()|Hard|| -|209|Minimum Size Subarray Sum|[Python](python/209 Minimum Size Subarray Sum.py) [Java]()|Medium|| -|222|Count Complete Tree Nodes|[Python](python/222 Count Complete Tree Nodes.py) [Java]()|Medium|| -|230|Kth Smallest Element in a BST|[Python](python/230 Kth Smallest Element in a BST.py) [Java]()|Medium|| -|240|Search a 2D Matrix II|[Python](python/240 Search a 2D Matrix II.py) [Java]()|Medium|| -|270|Closest Binary Search Tree Value|[Python](python/270 Closest Binary Search Tree Value.py) [Java]()|Easy|| -|275|H-Index II|[Python](python/275 H-Index II.py) [Java]()|Medium|| -|278|First Bad Version|[Python](python/278 First Bad Version.py) [Java]()|Easy|| -|287|Find the Duplicate Number|[Python](python/287 Find the Duplicate Number.py) [Java]()|Medium|| -|300|Longest Increasing Subsequence|[Python](python/300 Longest Increasing Subsequence.py) [Java]()|Medium|| -|302|Smallest Rectangle Enclosing Black Pixels|[Python](python/302 Smallest Rectangle Enclosing Black Pixels.py) [Java]()|Hard|| -|349|Intersection of Two Arrays|[Python](python/349 Intersection of Two Arrays.py) [Java]()|Easy|| -|350|Intersection of Two Arrays II|[Python](python/350 Intersection of Two Arrays II.py) [Java]()|Easy|| -|354|Russian Doll Envelopes|[Python](python/354 Russian Doll Envelopes.py) [Java]()|Hard|| -|363|Max Sum of Rectangle No Larger Than K|[Python](python/363 Max Sum of Rectangle No Larger Than K.py) [Java]()|Hard|| -|367|Valid Perfect Square|[Python](python/367 Valid Perfect Square.py) [Java]()|Easy|| -|374|Guess Number Higher or Lower|[Python](python/374 Guess Number Higher or Lower.py) [Java]()|Easy|| -|378|Kth Smallest Element in a Sorted Matrix|[Python](python/378 Kth Smallest Element in a Sorted Matrix.py) [Java]()|Medium|| -|392|Is Subsequence|[Python](python/392 Is Subsequence.py) [Java]()|Medium|| -|410|Split Array Largest Sum|[Python](python/410 Split Array Largest Sum.py) [Java]()|Hard|| -|436|Find Right Interval|[Python](python/436 Find Right Interval.py) [Java]()|Medium|| -|441|Arranging Coins|[Python](python/441 Arranging Coins.py) [Java]()|Easy|| -|454|4Sum II|[Python](python/454 4Sum II.py) [Java]()|Medium|| -|475|Heaters|[Python](python/475 Heaters.py) [Java]()|Easy|| -|483|Smallest Good Base|[Python](python/483 Smallest Good Base.py) [Java]()|Hard|| +|4|[Median of Two Sorted Arrays](https://leetcode.com/problems/median-of-two-sorted-arrays)|[Python](./python/004 Median of Two Sorted Arrays.py) [Java]()|Hard|| +|29|[Divide Two Integers](https://leetcode.com/problems/divide-two-integers)|[Python](./python/029 Divide Two Integers.py) [Java]()|Medium|| +|33|[Search in Rotated Sorted Array](https://leetcode.com/problems/search-in-rotated-sorted-array)|[Python](./python/033 Search in Rotated Sorted Array.py) [Java]()|Medium|| +|34|[Search for a Range](https://leetcode.com/problems/search-for-a-range)|[Python](./python/034 Search for a Range.py) [Java]()|Medium|| +|35|[Search Insert Position](https://leetcode.com/problems/search-insert-position)|[Python](./python/035 Search Insert Position.py) [Java]()|Easy|| +|50|[Pow(x, n)](https://leetcode.com/problems/pow(x,-n))|[Python](./python/050 Pow(x, n).py) [Java]()|Medium|| +|69|[Sqrt(x)](https://leetcode.com/problems/sqrt(x))|[Python](./python/069 Sqrt(x).py) [Java]()|Easy|| +|74|[Search a 2D Matrix](https://leetcode.com/problems/search-a-2d-matrix)|[Python](./python/074 Search a 2D Matrix.py) [Java]()|Medium|| +|81|[Search in Rotated Sorted Array II](https://leetcode.com/problems/search-in-rotated-sorted-array-ii)|[Python](./python/081 Search in Rotated Sorted Array II.py) [Java]()|Medium|| +|153|[Find Minimum in Rotated Sorted Array](https://leetcode.com/problems/find-minimum-in-rotated-sorted-array)|[Python](./python/153 Find Minimum in Rotated Sorted Array.py) [Java]()|Medium|| +|154|[Find Minimum in Rotated Sorted Array II](https://leetcode.com/problems/find-minimum-in-rotated-sorted-array-ii)|[Python](./python/154 Find Minimum in Rotated Sorted Array II.py) [Java]()|Hard|| +|162|[Find Peak Element](https://leetcode.com/problems/find-peak-element)|[Python](./python/162 Find Peak Element.py) [Java]()|Medium|| +|167|[Two Sum II - Input array is sorted](https://leetcode.com/problems/two-sum-ii---input-array-is-sorted)|[Python](./python/167 Two Sum II - Input array is sorted.py) [Java]()|Easy|| +|174|[Dungeon Game](https://leetcode.com/problems/dungeon-game)|[Python](./python/174 Dungeon Game.py) [Java]()|Hard|| +|209|[Minimum Size Subarray Sum](https://leetcode.com/problems/minimum-size-subarray-sum)|[Python](./python/209 Minimum Size Subarray Sum.py) [Java]()|Medium|| +|222|[Count Complete Tree Nodes](https://leetcode.com/problems/count-complete-tree-nodes)|[Python](./python/222 Count Complete Tree Nodes.py) [Java]()|Medium|| +|230|[Kth Smallest Element in a BST](https://leetcode.com/problems/kth-smallest-element-in-a-bst)|[Python](./python/230 Kth Smallest Element in a BST.py) [Java]()|Medium|| +|240|[Search a 2D Matrix II](https://leetcode.com/problems/search-a-2d-matrix-ii)|[Python](./python/240 Search a 2D Matrix II.py) [Java]()|Medium|| +|270|[Closest Binary Search Tree Value](https://leetcode.com/problems/closest-binary-search-tree-value)|[Python](./python/270 Closest Binary Search Tree Value.py) [Java]()|Easy|| +|275|[H-Index II](https://leetcode.com/problems/h-index-ii)|[Python](./python/275 H-Index II.py) [Java]()|Medium|| +|278|[First Bad Version](https://leetcode.com/problems/first-bad-version)|[Python](./python/278 First Bad Version.py) [Java]()|Easy|| +|287|[Find the Duplicate Number](https://leetcode.com/problems/find-the-duplicate-number)|[Python](./python/287 Find the Duplicate Number.py) [Java]()|Medium|| +|300|[Longest Increasing Subsequence](https://leetcode.com/problems/longest-increasing-subsequence)|[Python](./python/300 Longest Increasing Subsequence.py) [Java]()|Medium|| +|302|[Smallest Rectangle Enclosing Black Pixels](https://leetcode.com/problems/smallest-rectangle-enclosing-black-pixels)|[Python](./python/302 Smallest Rectangle Enclosing Black Pixels.py) [Java]()|Hard|| +|349|[Intersection of Two Arrays](https://leetcode.com/problems/intersection-of-two-arrays)|[Python](./python/349 Intersection of Two Arrays.py) [Java]()|Easy|| +|350|[Intersection of Two Arrays II](https://leetcode.com/problems/intersection-of-two-arrays-ii)|[Python](./python/350 Intersection of Two Arrays II.py) [Java]()|Easy|| +|354|[Russian Doll Envelopes](https://leetcode.com/problems/russian-doll-envelopes)|[Python](./python/354 Russian Doll Envelopes.py) [Java]()|Hard|| +|363|[Max Sum of Rectangle No Larger Than K](https://leetcode.com/problems/max-sum-of-rectangle-no-larger-than-k)|[Python](./python/363 Max Sum of Rectangle No Larger Than K.py) [Java]()|Hard|| +|367|[Valid Perfect Square](https://leetcode.com/problems/valid-perfect-square)|[Python](./python/367 Valid Perfect Square.py) [Java]()|Easy|| +|374|[Guess Number Higher or Lower](https://leetcode.com/problems/guess-number-higher-or-lower)|[Python](./python/374 Guess Number Higher or Lower.py) [Java]()|Easy|| +|378|[Kth Smallest Element in a Sorted Matrix](https://leetcode.com/problems/kth-smallest-element-in-a-sorted-matrix)|[Python](./python/378 Kth Smallest Element in a Sorted Matrix.py) [Java]()|Medium|| +|392|[Is Subsequence](https://leetcode.com/problems/is-subsequence)|[Python](./python/392 Is Subsequence.py) [Java]()|Medium|| +|410|[Split Array Largest Sum](https://leetcode.com/problems/split-array-largest-sum)|[Python](./python/410 Split Array Largest Sum.py) [Java]()|Hard|| +|436|[Find Right Interval](https://leetcode.com/problems/find-right-interval)|[Python](./python/436 Find Right Interval.py) [Java]()|Medium|| +|441|[Arranging Coins](https://leetcode.com/problems/arranging-coins)|[Python](./python/441 Arranging Coins.py) [Java]()|Easy|| +|454|[4Sum II](https://leetcode.com/problems/4sum-ii)|[Python](./python/454 4Sum II.py) [Java]()|Medium|| +|475|[Heaters](https://leetcode.com/problems/heaters)|[Python](./python/475 Heaters.py) [Java]()|Easy|| +|483|[Smallest Good Base](https://leetcode.com/problems/smallest-good-base)|[Python](./python/483 Smallest Good Base.py) [Java]()|Hard|| ## Divide and Conquer | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|4|Median of Two Sorted Arrays|[Python](python/004 Median of Two Sorted Arrays.py) [Java]()|Hard|| -|23|Merge k Sorted Lists|[Python](python/023 Merge k Sorted Lists.py) [Java]()|Hard|| -|53|Maximum Subarray|[Python](python/053 Maximum Subarray.py) [Java]()|Easy|| -|169|Majority Element|[Python](python/169 Majority Element.py) [Java]()|Easy|| -|215|Kth Largest Element in an Array|[Python](python/215 Kth Largest Element in an Array.py) [Java]()|Medium|| -|218|The Skyline Problem|[Python](python/218 The Skyline Problem.py) [Java]()|Hard|| -|240|Search a 2D Matrix II|[Python](python/240 Search a 2D Matrix II.py) [Java]()|Medium|| -|241|Different Ways to Add Parentheses|[Python](python/241 Different Ways to Add Parentheses.py) [Java]()|Medium|| -|282|Expression Add Operators|[Python](python/282 Expression Add Operators.py) [Java]()|Hard|| -|312|Burst Balloons|[Python](python/312 Burst Balloons.py) [Java]()|Hard|| -|315|Count of Smaller Numbers After Self|[Python](python/315 Count of Smaller Numbers After Self.py) [Java]()|Hard|| -|327|Count of Range Sum|[Python](python/327 Count of Range Sum.py) [Java]()|Hard|| -|493|Reverse Pairs|[Python](python/493 Reverse Pairs.py) [Java]()|Hard|| -|514|Freedom Trail|[Python](python/514 Freedom Trail.py) [Java]()|Hard|| +|4|[Median of Two Sorted Arrays](https://leetcode.com/problems/median-of-two-sorted-arrays)|[Python](./python/004 Median of Two Sorted Arrays.py) [Java]()|Hard|| +|23|[Merge k Sorted Lists](https://leetcode.com/problems/merge-k-sorted-lists)|[Python](./python/023 Merge k Sorted Lists.py) [Java]()|Hard|| +|53|[Maximum Subarray](https://leetcode.com/problems/maximum-subarray)|[Python](./python/053 Maximum Subarray.py) [Java]()|Easy|| +|169|[Majority Element](https://leetcode.com/problems/majority-element)|[Python](./python/169 Majority Element.py) [Java]()|Easy|| +|215|[Kth Largest Element in an Array](https://leetcode.com/problems/kth-largest-element-in-an-array)|[Python](./python/215 Kth Largest Element in an Array.py) [Java]()|Medium|| +|218|[The Skyline Problem](https://leetcode.com/problems/the-skyline-problem)|[Python](./python/218 The Skyline Problem.py) [Java]()|Hard|| +|240|[Search a 2D Matrix II](https://leetcode.com/problems/search-a-2d-matrix-ii)|[Python](./python/240 Search a 2D Matrix II.py) [Java]()|Medium|| +|241|[Different Ways to Add Parentheses](https://leetcode.com/problems/different-ways-to-add-parentheses)|[Python](./python/241 Different Ways to Add Parentheses.py) [Java]()|Medium|| +|282|[Expression Add Operators](https://leetcode.com/problems/expression-add-operators)|[Python](./python/282 Expression Add Operators.py) [Java]()|Hard|| +|312|[Burst Balloons](https://leetcode.com/problems/burst-balloons)|[Python](./python/312 Burst Balloons.py) [Java]()|Hard|| +|315|[Count of Smaller Numbers After Self](https://leetcode.com/problems/count-of-smaller-numbers-after-self)|[Python](./python/315 Count of Smaller Numbers After Self.py) [Java]()|Hard|| +|327|[Count of Range Sum](https://leetcode.com/problems/count-of-range-sum)|[Python](./python/327 Count of Range Sum.py) [Java]()|Hard|| +|493|[Reverse Pairs](https://leetcode.com/problems/reverse-pairs)|[Python](./python/493 Reverse Pairs.py) [Java]()|Hard|| +|514|[Freedom Trail](https://leetcode.com/problems/freedom-trail)|[Python](./python/514 Freedom Trail.py) [Java]()|Hard|| ## Dynamic Programming | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|10|Regular Expression Matching|[Python](python/010 Regular Expression Matching.py) [Java]()|Hard|| -|32|Longest Valid Parentheses|[Python](python/032 Longest Valid Parentheses.py) [Java]()|Hard|| -|44|Wildcard Matching|[Python](python/044 Wildcard Matching.py) [Java]()|Hard|| -|53|Maximum Subarray|[Python](python/053 Maximum Subarray.py) [Java]()|Easy|| -|62|Unique Paths|[Python](python/062 Unique Paths.py) [Java]()|Medium|| -|63|Unique Paths II|[Python](python/063 Unique Paths II.py) [Java]()|Medium|| -|64|Minimum Path Sum|[Python](python/064 Minimum Path Sum.py) [Java]()|Medium|| -|70|Climbing Stairs|[Python](python/070 Climbing Stairs.py) [Java]()|Easy|| -|72|Edit Distance|[Python](python/072 Edit Distance.py) [Java]()|Hard|| -|85|Maximal Rectangle|[Python](python/085 Maximal Rectangle.py) [Java]()|Hard|| -|87|Scramble String|[Python](python/087 Scramble String.py) [Java]()|Hard|| -|91|Decode Ways|[Python](python/091 Decode Ways.py) [Java]()|Medium|| -|95|Unique Binary Search Trees II|[Python](python/095 Unique Binary Search Trees II.py) [Java]()|Medium|| -|96|Unique Binary Search Trees|[Python](python/096 Unique Binary Search Trees.py) [Java]()|Medium|| -|97|Interleaving String|[Python](python/097 Interleaving String.py) [Java]()|Hard|| -|115|Distinct Subsequences|[Python](python/115 Distinct Subsequences.py) [Java]()|Hard|| -|120|Triangle|[Python](python/120 Triangle.py) [Java]()|Medium|| -|121|Best Time to Buy and Sell Stock|[Python](python/121 Best Time to Buy and Sell Stock.py) [Java]()|Easy|| -|123|Best Time to Buy and Sell Stock III|[Python](python/123 Best Time to Buy and Sell Stock III.py) [Java]()|Hard|| -|132|Palindrome Partitioning II|[Python](python/132 Palindrome Partitioning II.py) [Java]()|Hard|| -|139|Word Break|[Python](python/139 Word Break.py) [Java]()|Medium|| -|140|Word Break II|[Python](python/140 Word Break II.py) [Java]()|Hard|| -|152|Maximum Product Subarray|[Python](python/152 Maximum Product Subarray.py) [Java]()|Medium|| -|174|Dungeon Game|[Python](python/174 Dungeon Game.py) [Java]()|Hard|| -|188|Best Time to Buy and Sell Stock IV|[Python](python/188 Best Time to Buy and Sell Stock IV.py) [Java]()|Hard|| -|198|House Robber|[Python](python/198 House Robber.py) [Java]()|Easy|| -|213|House Robber II|[Python](python/213 House Robber II.py) [Java]()|Medium|| -|221|Maximal Square|[Python](python/221 Maximal Square.py) [Java]()|Medium|| -|256|Paint House|[Python](python/256 Paint House.py) [Java]()|Easy|| -|264|Ugly Number II|[Python](python/264 Ugly Number II.py) [Java]()|Medium|| -|265|Paint House II|[Python](python/265 Paint House II.py) [Java]()|Hard|| -|276|Paint Fence|[Python](python/276 Paint Fence.py) [Java]()|Easy|| -|279|Perfect Squares|[Python](python/279 Perfect Squares.py) [Java]()|Medium|| -|300|Longest Increasing Subsequence|[Python](python/300 Longest Increasing Subsequence.py) [Java]()|Medium|| -|303|Range Sum Query - Immutable|[Python](python/303 Range Sum Query - Immutable.py) [Java]()|Easy|| -|304|Range Sum Query 2D - Immutable|[Python](python/304 Range Sum Query 2D - Immutable.py) [Java]()|Medium|| -|309|Best Time to Buy and Sell Stock with Cooldown|[Python](python/309 Best Time to Buy and Sell Stock with Cooldown.py) [Java]()|Medium|| -|312|Burst Balloons|[Python](python/312 Burst Balloons.py) [Java]()|Hard|| -|321|Create Maximum Number|[Python](python/321 Create Maximum Number.py) [Java]()|Hard|| -|322|Coin Change|[Python](python/322 Coin Change.py) [Java]()|Medium|| -|338|Counting Bits|[Python](python/338 Counting Bits.py) [Java]()|Medium|| -|343|Integer Break|[Python](python/343 Integer Break.py) [Java]()|Medium|| -|351|Android Unlock Patterns|[Python](python/351 Android Unlock Patterns.py) [Java]()|Medium|| -|354|Russian Doll Envelopes|[Python](python/354 Russian Doll Envelopes.py) [Java]()|Hard|| -|357|Count Numbers with Unique Digits|[Python](python/357 Count Numbers with Unique Digits.py) [Java]()|Medium|| -|361|Bomb Enemy|[Python](python/361 Bomb Enemy.py) [Java]()|Medium|| -|363|Max Sum of Rectangle No Larger Than K|[Python](python/363 Max Sum of Rectangle No Larger Than K.py) [Java]()|Hard|| -|368|Largest Divisible Subset|[Python](python/368 Largest Divisible Subset.py) [Java]()|Medium|| -|375|Guess Number Higher or Lower II|[Python](python/375 Guess Number Higher or Lower II.py) [Java]()|Medium|| -|376|Wiggle Subsequence|[Python](python/376 Wiggle Subsequence.py) [Java]()|Medium|| -|377|Combination Sum IV|[Python](python/377 Combination Sum IV.py) [Java]()|Medium|| -|392|Is Subsequence|[Python](python/392 Is Subsequence.py) [Java]()|Medium|| -|403|Frog Jump|[Python](python/403 Frog Jump.py) [Java]()|Hard|| -|410|Split Array Largest Sum|[Python](python/410 Split Array Largest Sum.py) [Java]()|Hard|| -|413|Arithmetic Slices|[Python](python/413 Arithmetic Slices.py) [Java]()|Medium|| -|416|Partition Equal Subset Sum|[Python](python/416 Partition Equal Subset Sum.py) [Java]()|Medium|| -|418|Sentence Screen Fitting|[Python](python/418 Sentence Screen Fitting.py) [Java]()|Medium|| -|446|Arithmetic Slices II - Subsequence|[Python](python/446 Arithmetic Slices II - Subsequence.py) [Java]()|Hard|| -|464|Can I Win|[Python](python/464 Can I Win.py) [Java]()|Medium|| -|466|Count The Repetitions|[Python](python/466 Count The Repetitions.py) [Java]()|Hard|| -|467|Unique Substrings in Wraparound String|[Python](python/467 Unique Substrings in Wraparound String.py) [Java]()|Medium|| -|471|Encode String with Shortest Length|[Python](python/471 Encode String with Shortest Length.py) [Java]()|Hard|| -|472|Concatenated Words|[Python](python/472 Concatenated Words.py) [Java]()|Hard|| -|474|Ones and Zeroes|[Python](python/474 Ones and Zeroes.py) [Java]()|Medium|| -|486|Predict the Winner|[Python](python/486 Predict the Winner.py) [Java]()|Medium|| -|494|Target Sum|[Python](python/494 Target Sum.py) [Java]()|Medium|| -|514|Freedom Trail|[Python](python/514 Freedom Trail.py) [Java]()|Hard|| -|516|Longest Palindromic Subsequence|[Python](python/516 Longest Palindromic Subsequence.py) [Java]()|Medium|| -|517|Super Washing Machines|[Python](python/517 Super Washing Machines.py) [Java]()|Hard|| -|523|Continuous Subarray Sum|[Python](python/523 Continuous Subarray Sum.py) [Java]()|Medium|| -|546|Remove Boxes|[Python](python/546 Remove Boxes.py) [Java]()|Hard|| -|552|Student Attendance Record II|[Python](python/552 Student Attendance Record II.py) [Java]()|Hard|| -|568|Maximum Vacation Days|[Python](python/568 Maximum Vacation Days.py) [Java]()|Hard|| +|10|[Regular Expression Matching](https://leetcode.com/problems/regular-expression-matching)|[Python](./python/010 Regular Expression Matching.py) [Java]()|Hard|| +|32|[Longest Valid Parentheses](https://leetcode.com/problems/longest-valid-parentheses)|[Python](./python/032 Longest Valid Parentheses.py) [Java]()|Hard|| +|44|[Wildcard Matching](https://leetcode.com/problems/wildcard-matching)|[Python](./python/044 Wildcard Matching.py) [Java]()|Hard|| +|53|[Maximum Subarray](https://leetcode.com/problems/maximum-subarray)|[Python](./python/053 Maximum Subarray.py) [Java]()|Easy|| +|62|[Unique Paths](https://leetcode.com/problems/unique-paths)|[Python](./python/062 Unique Paths.py) [Java]()|Medium|| +|63|[Unique Paths II](https://leetcode.com/problems/unique-paths-ii)|[Python](./python/063 Unique Paths II.py) [Java]()|Medium|| +|64|[Minimum Path Sum](https://leetcode.com/problems/minimum-path-sum)|[Python](./python/064 Minimum Path Sum.py) [Java]()|Medium|| +|70|[Climbing Stairs](https://leetcode.com/problems/climbing-stairs)|[Python](./python/070 Climbing Stairs.py) [Java]()|Easy|| +|72|[Edit Distance](https://leetcode.com/problems/edit-distance)|[Python](./python/072 Edit Distance.py) [Java]()|Hard|| +|85|[Maximal Rectangle](https://leetcode.com/problems/maximal-rectangle)|[Python](./python/085 Maximal Rectangle.py) [Java]()|Hard|| +|87|[Scramble String](https://leetcode.com/problems/scramble-string)|[Python](./python/087 Scramble String.py) [Java]()|Hard|| +|91|[Decode Ways](https://leetcode.com/problems/decode-ways)|[Python](./python/091 Decode Ways.py) [Java]()|Medium|| +|95|[Unique Binary Search Trees II](https://leetcode.com/problems/unique-binary-search-trees-ii)|[Python](./python/095 Unique Binary Search Trees II.py) [Java]()|Medium|| +|96|[Unique Binary Search Trees](https://leetcode.com/problems/unique-binary-search-trees)|[Python](./python/096 Unique Binary Search Trees.py) [Java]()|Medium|| +|97|[Interleaving String](https://leetcode.com/problems/interleaving-string)|[Python](./python/097 Interleaving String.py) [Java]()|Hard|| +|115|[Distinct Subsequences](https://leetcode.com/problems/distinct-subsequences)|[Python](./python/115 Distinct Subsequences.py) [Java]()|Hard|| +|120|[Triangle](https://leetcode.com/problems/triangle)|[Python](./python/120 Triangle.py) [Java]()|Medium|| +|121|[Best Time to Buy and Sell Stock](https://leetcode.com/problems/best-time-to-buy-and-sell-stock)|[Python](./python/121 Best Time to Buy and Sell Stock.py) [Java]()|Easy|| +|123|[Best Time to Buy and Sell Stock III](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iii)|[Python](./python/123 Best Time to Buy and Sell Stock III.py) [Java]()|Hard|| +|132|[Palindrome Partitioning II](https://leetcode.com/problems/palindrome-partitioning-ii)|[Python](./python/132 Palindrome Partitioning II.py) [Java]()|Hard|| +|139|[Word Break](https://leetcode.com/problems/word-break)|[Python](./python/139 Word Break.py) [Java]()|Medium|| +|140|[Word Break II](https://leetcode.com/problems/word-break-ii)|[Python](./python/140 Word Break II.py) [Java]()|Hard|| +|152|[Maximum Product Subarray](https://leetcode.com/problems/maximum-product-subarray)|[Python](./python/152 Maximum Product Subarray.py) [Java]()|Medium|| +|174|[Dungeon Game](https://leetcode.com/problems/dungeon-game)|[Python](./python/174 Dungeon Game.py) [Java]()|Hard|| +|188|[Best Time to Buy and Sell Stock IV](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iv)|[Python](./python/188 Best Time to Buy and Sell Stock IV.py) [Java]()|Hard|| +|198|[House Robber](https://leetcode.com/problems/house-robber)|[Python](./python/198 House Robber.py) [Java]()|Easy|| +|213|[House Robber II](https://leetcode.com/problems/house-robber-ii)|[Python](./python/213 House Robber II.py) [Java]()|Medium|| +|221|[Maximal Square](https://leetcode.com/problems/maximal-square)|[Python](./python/221 Maximal Square.py) [Java]()|Medium|| +|256|[Paint House](https://leetcode.com/problems/paint-house)|[Python](./python/256 Paint House.py) [Java]()|Easy|| +|264|[Ugly Number II](https://leetcode.com/problems/ugly-number-ii)|[Python](./python/264 Ugly Number II.py) [Java]()|Medium|| +|265|[Paint House II](https://leetcode.com/problems/paint-house-ii)|[Python](./python/265 Paint House II.py) [Java]()|Hard|| +|276|[Paint Fence](https://leetcode.com/problems/paint-fence)|[Python](./python/276 Paint Fence.py) [Java]()|Easy|| +|279|[Perfect Squares](https://leetcode.com/problems/perfect-squares)|[Python](./python/279 Perfect Squares.py) [Java]()|Medium|| +|300|[Longest Increasing Subsequence](https://leetcode.com/problems/longest-increasing-subsequence)|[Python](./python/300 Longest Increasing Subsequence.py) [Java]()|Medium|| +|303|[Range Sum Query - Immutable](https://leetcode.com/problems/range-sum-query---immutable)|[Python](./python/303 Range Sum Query - Immutable.py) [Java]()|Easy|| +|304|[Range Sum Query 2D - Immutable](https://leetcode.com/problems/range-sum-query-2d---immutable)|[Python](./python/304 Range Sum Query 2D - Immutable.py) [Java]()|Medium|| +|309|[Best Time to Buy and Sell Stock with Cooldown](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-cooldown)|[Python](./python/309 Best Time to Buy and Sell Stock with Cooldown.py) [Java]()|Medium|| +|312|[Burst Balloons](https://leetcode.com/problems/burst-balloons)|[Python](./python/312 Burst Balloons.py) [Java]()|Hard|| +|321|[Create Maximum Number](https://leetcode.com/problems/create-maximum-number)|[Python](./python/321 Create Maximum Number.py) [Java]()|Hard|| +|322|[Coin Change](https://leetcode.com/problems/coin-change)|[Python](./python/322 Coin Change.py) [Java]()|Medium|| +|338|[Counting Bits](https://leetcode.com/problems/counting-bits)|[Python](./python/338 Counting Bits.py) [Java]()|Medium|| +|343|[Integer Break](https://leetcode.com/problems/integer-break)|[Python](./python/343 Integer Break.py) [Java]()|Medium|| +|351|[Android Unlock Patterns](https://leetcode.com/problems/android-unlock-patterns)|[Python](./python/351 Android Unlock Patterns.py) [Java]()|Medium|| +|354|[Russian Doll Envelopes](https://leetcode.com/problems/russian-doll-envelopes)|[Python](./python/354 Russian Doll Envelopes.py) [Java]()|Hard|| +|357|[Count Numbers with Unique Digits](https://leetcode.com/problems/count-numbers-with-unique-digits)|[Python](./python/357 Count Numbers with Unique Digits.py) [Java]()|Medium|| +|361|[Bomb Enemy](https://leetcode.com/problems/bomb-enemy)|[Python](./python/361 Bomb Enemy.py) [Java]()|Medium|| +|363|[Max Sum of Rectangle No Larger Than K](https://leetcode.com/problems/max-sum-of-rectangle-no-larger-than-k)|[Python](./python/363 Max Sum of Rectangle No Larger Than K.py) [Java]()|Hard|| +|368|[Largest Divisible Subset](https://leetcode.com/problems/largest-divisible-subset)|[Python](./python/368 Largest Divisible Subset.py) [Java]()|Medium|| +|375|[Guess Number Higher or Lower II](https://leetcode.com/problems/guess-number-higher-or-lower-ii)|[Python](./python/375 Guess Number Higher or Lower II.py) [Java]()|Medium|| +|376|[Wiggle Subsequence](https://leetcode.com/problems/wiggle-subsequence)|[Python](./python/376 Wiggle Subsequence.py) [Java]()|Medium|| +|377|[Combination Sum IV](https://leetcode.com/problems/combination-sum-iv)|[Python](./python/377 Combination Sum IV.py) [Java]()|Medium|| +|392|[Is Subsequence](https://leetcode.com/problems/is-subsequence)|[Python](./python/392 Is Subsequence.py) [Java]()|Medium|| +|403|[Frog Jump](https://leetcode.com/problems/frog-jump)|[Python](./python/403 Frog Jump.py) [Java]()|Hard|| +|410|[Split Array Largest Sum](https://leetcode.com/problems/split-array-largest-sum)|[Python](./python/410 Split Array Largest Sum.py) [Java]()|Hard|| +|413|[Arithmetic Slices](https://leetcode.com/problems/arithmetic-slices)|[Python](./python/413 Arithmetic Slices.py) [Java]()|Medium|| +|416|[Partition Equal Subset Sum](https://leetcode.com/problems/partition-equal-subset-sum)|[Python](./python/416 Partition Equal Subset Sum.py) [Java]()|Medium|| +|418|[Sentence Screen Fitting](https://leetcode.com/problems/sentence-screen-fitting)|[Python](./python/418 Sentence Screen Fitting.py) [Java]()|Medium|| +|446|[Arithmetic Slices II - Subsequence](https://leetcode.com/problems/arithmetic-slices-ii---subsequence)|[Python](./python/446 Arithmetic Slices II - Subsequence.py) [Java]()|Hard|| +|464|[Can I Win](https://leetcode.com/problems/can-i-win)|[Python](./python/464 Can I Win.py) [Java]()|Medium|| +|466|[Count The Repetitions](https://leetcode.com/problems/count-the-repetitions)|[Python](./python/466 Count The Repetitions.py) [Java]()|Hard|| +|467|[Unique Substrings in Wraparound String](https://leetcode.com/problems/unique-substrings-in-wraparound-string)|[Python](./python/467 Unique Substrings in Wraparound String.py) [Java]()|Medium|| +|471|[Encode String with Shortest Length](https://leetcode.com/problems/encode-string-with-shortest-length)|[Python](./python/471 Encode String with Shortest Length.py) [Java]()|Hard|| +|472|[Concatenated Words](https://leetcode.com/problems/concatenated-words)|[Python](./python/472 Concatenated Words.py) [Java]()|Hard|| +|474|[Ones and Zeroes](https://leetcode.com/problems/ones-and-zeroes)|[Python](./python/474 Ones and Zeroes.py) [Java]()|Medium|| +|486|[Predict the Winner](https://leetcode.com/problems/predict-the-winner)|[Python](./python/486 Predict the Winner.py) [Java]()|Medium|| +|494|[Target Sum](https://leetcode.com/problems/target-sum)|[Python](./python/494 Target Sum.py) [Java]()|Medium|| +|514|[Freedom Trail](https://leetcode.com/problems/freedom-trail)|[Python](./python/514 Freedom Trail.py) [Java]()|Hard|| +|516|[Longest Palindromic Subsequence](https://leetcode.com/problems/longest-palindromic-subsequence)|[Python](./python/516 Longest Palindromic Subsequence.py) [Java]()|Medium|| +|517|[Super Washing Machines](https://leetcode.com/problems/super-washing-machines)|[Python](./python/517 Super Washing Machines.py) [Java]()|Hard|| +|523|[Continuous Subarray Sum](https://leetcode.com/problems/continuous-subarray-sum)|[Python](./python/523 Continuous Subarray Sum.py) [Java]()|Medium|| +|546|[Remove Boxes](https://leetcode.com/problems/remove-boxes)|[Python](./python/546 Remove Boxes.py) [Java]()|Hard|| +|552|[Student Attendance Record II](https://leetcode.com/problems/student-attendance-record-ii)|[Python](./python/552 Student Attendance Record II.py) [Java]()|Hard|| +|568|[Maximum Vacation Days](https://leetcode.com/problems/maximum-vacation-days)|[Python](./python/568 Maximum Vacation Days.py) [Java]()|Hard|| ## Backtracking | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|10|Regular Expression Matching|[Python](python/010 Regular Expression Matching.py) [Java]()|Hard|| -|17|Letter Combinations of a Phone Number|[Python](python/017 Letter Combinations of a Phone Number.py) [Java]()|Medium|| -|22|Generate Parentheses|[Python](python/022 Generate Parentheses.py) [Java]()|Medium|| -|37|Sudoku Solver|[Python](python/037 Sudoku Solver.py) [Java]()|Hard|| -|39|Combination Sum|[Python](python/039 Combination Sum.py) [Java]()|Medium|| -|40|Combination Sum II|[Python](python/040 Combination Sum II.py) [Java]()|Medium|| -|44|Wildcard Matching|[Python](python/044 Wildcard Matching.py) [Java]()|Hard|| -|46|Permutations|[Python](python/046 Permutations.py) [Java]()|Medium|| -|47|Permutations II|[Python](python/047 Permutations II.py) [Java]()|Medium|| -|51|N-Queens|[Python](python/051 N-Queens.py) [Java]()|Hard|| -|52|N-Queens II|[Python](python/052 N-Queens II.py) [Java]()|Hard|| -|60|Permutation Sequence|[Python](python/060 Permutation Sequence.py) [Java]()|Medium|| -|77|Combinations|[Python](python/077 Combinations.py) [Java]()|Medium|| -|78|Subsets|[Python](python/078 Subsets.py) [Java]()|Medium|| -|79|Word Search|[Python](python/079 Word Search.py) [Java]()|Medium|| -|89|Gray Code|[Python](python/089 Gray Code.py) [Java]()|Medium|| -|90|Subsets II|[Python](python/090 Subsets II.py) [Java]()|Medium|| -|93|Restore IP Addresses|[Python](python/093 Restore IP Addresses.py) [Java]()|Medium|| -|126|Word Ladder II|[Python](python/126 Word Ladder II.py) [Java]()|Hard|| -|131|Palindrome Partitioning|[Python](python/131 Palindrome Partitioning.py) [Java]()|Medium|| -|140|Word Break II|[Python](python/140 Word Break II.py) [Java]()|Hard|| -|211|Add and Search Word - Data structure design|[Python](python/211 Add and Search Word - Data structure design.py) [Java]()|Medium|| -|212|Word Search II|[Python](python/212 Word Search II.py) [Java]()|Hard|| -|216|Combination Sum III|[Python](python/216 Combination Sum III.py) [Java]()|Medium|| -|254|Factor Combinations|[Python](python/254 Factor Combinations.py) [Java]()|Medium|| -|267|Palindrome Permutation II|[Python](python/267 Palindrome Permutation II.py) [Java]()|Medium|| -|291|Word Pattern II|[Python](python/291 Word Pattern II.py) [Java]()|Hard|| -|294|Flip Game II|[Python](python/294 Flip Game II.py) [Java]()|Medium|| -|320|Generalized Abbreviation|[Python](python/320 Generalized Abbreviation.py) [Java]()|Medium|| -|351|Android Unlock Patterns|[Python](python/351 Android Unlock Patterns.py) [Java]()|Medium|| -|357|Count Numbers with Unique Digits|[Python](python/357 Count Numbers with Unique Digits.py) [Java]()|Medium|| -|401|Binary Watch|[Python](python/401 Binary Watch.py) [Java]()|Easy|| -|411|Minimum Unique Word Abbreviation|[Python](python/411 Minimum Unique Word Abbreviation.py) [Java]()|Hard|| -|425|Word Squares|[Python](python/425 Word Squares.py) [Java]()|Hard|| -|526|Beautiful Arrangement|[Python](python/526 Beautiful Arrangement.py) [Java]()|Medium|| +|10|[Regular Expression Matching](https://leetcode.com/problems/regular-expression-matching)|[Python](./python/010 Regular Expression Matching.py) [Java]()|Hard|| +|17|[Letter Combinations of a Phone Number](https://leetcode.com/problems/letter-combinations-of-a-phone-number)|[Python](./python/017 Letter Combinations of a Phone Number.py) [Java]()|Medium|| +|22|[Generate Parentheses](https://leetcode.com/problems/generate-parentheses)|[Python](./python/022 Generate Parentheses.py) [Java]()|Medium|| +|37|[Sudoku Solver](https://leetcode.com/problems/sudoku-solver)|[Python](./python/037 Sudoku Solver.py) [Java]()|Hard|| +|39|[Combination Sum](https://leetcode.com/problems/combination-sum)|[Python](./python/039 Combination Sum.py) [Java]()|Medium|| +|40|[Combination Sum II](https://leetcode.com/problems/combination-sum-ii)|[Python](./python/040 Combination Sum II.py) [Java]()|Medium|| +|44|[Wildcard Matching](https://leetcode.com/problems/wildcard-matching)|[Python](./python/044 Wildcard Matching.py) [Java]()|Hard|| +|46|[Permutations](https://leetcode.com/problems/permutations)|[Python](./python/046 Permutations.py) [Java]()|Medium|| +|47|[Permutations II](https://leetcode.com/problems/permutations-ii)|[Python](./python/047 Permutations II.py) [Java]()|Medium|| +|51|[N-Queens](https://leetcode.com/problems/n-queens)|[Python](./python/051 N-Queens.py) [Java]()|Hard|| +|52|[N-Queens II](https://leetcode.com/problems/n-queens-ii)|[Python](./python/052 N-Queens II.py) [Java]()|Hard|| +|60|[Permutation Sequence](https://leetcode.com/problems/permutation-sequence)|[Python](./python/060 Permutation Sequence.py) [Java]()|Medium|| +|77|[Combinations](https://leetcode.com/problems/combinations)|[Python](./python/077 Combinations.py) [Java]()|Medium|| +|78|[Subsets](https://leetcode.com/problems/subsets)|[Python](./python/078 Subsets.py) [Java]()|Medium|| +|79|[Word Search](https://leetcode.com/problems/word-search)|[Python](./python/079 Word Search.py) [Java]()|Medium|| +|89|[Gray Code](https://leetcode.com/problems/gray-code)|[Python](./python/089 Gray Code.py) [Java]()|Medium|| +|90|[Subsets II](https://leetcode.com/problems/subsets-ii)|[Python](./python/090 Subsets II.py) [Java]()|Medium|| +|93|[Restore IP Addresses](https://leetcode.com/problems/restore-ip-addresses)|[Python](./python/093 Restore IP Addresses.py) [Java]()|Medium|| +|126|[Word Ladder II](https://leetcode.com/problems/word-ladder-ii)|[Python](./python/126 Word Ladder II.py) [Java]()|Hard|| +|131|[Palindrome Partitioning](https://leetcode.com/problems/palindrome-partitioning)|[Python](./python/131 Palindrome Partitioning.py) [Java]()|Medium|| +|140|[Word Break II](https://leetcode.com/problems/word-break-ii)|[Python](./python/140 Word Break II.py) [Java]()|Hard|| +|211|[Add and Search Word - Data structure design](https://leetcode.com/problems/add-and-search-word---data-structure-design)|[Python](./python/211 Add and Search Word - Data structure design.py) [Java]()|Medium|| +|212|[Word Search II](https://leetcode.com/problems/word-search-ii)|[Python](./python/212 Word Search II.py) [Java]()|Hard|| +|216|[Combination Sum III](https://leetcode.com/problems/combination-sum-iii)|[Python](./python/216 Combination Sum III.py) [Java]()|Medium|| +|254|[Factor Combinations](https://leetcode.com/problems/factor-combinations)|[Python](./python/254 Factor Combinations.py) [Java]()|Medium|| +|267|[Palindrome Permutation II](https://leetcode.com/problems/palindrome-permutation-ii)|[Python](./python/267 Palindrome Permutation II.py) [Java]()|Medium|| +|291|[Word Pattern II](https://leetcode.com/problems/word-pattern-ii)|[Python](./python/291 Word Pattern II.py) [Java]()|Hard|| +|294|[Flip Game II](https://leetcode.com/problems/flip-game-ii)|[Python](./python/294 Flip Game II.py) [Java]()|Medium|| +|320|[Generalized Abbreviation](https://leetcode.com/problems/generalized-abbreviation)|[Python](./python/320 Generalized Abbreviation.py) [Java]()|Medium|| +|351|[Android Unlock Patterns](https://leetcode.com/problems/android-unlock-patterns)|[Python](./python/351 Android Unlock Patterns.py) [Java]()|Medium|| +|357|[Count Numbers with Unique Digits](https://leetcode.com/problems/count-numbers-with-unique-digits)|[Python](./python/357 Count Numbers with Unique Digits.py) [Java]()|Medium|| +|401|[Binary Watch](https://leetcode.com/problems/binary-watch)|[Python](./python/401 Binary Watch.py) [Java]()|Easy|| +|411|[Minimum Unique Word Abbreviation](https://leetcode.com/problems/minimum-unique-word-abbreviation)|[Python](./python/411 Minimum Unique Word Abbreviation.py) [Java]()|Hard|| +|425|[Word Squares](https://leetcode.com/problems/word-squares)|[Python](./python/425 Word Squares.py) [Java]()|Hard|| +|526|[Beautiful Arrangement](https://leetcode.com/problems/beautiful-arrangement)|[Python](./python/526 Beautiful Arrangement.py) [Java]()|Medium|| ## Stack | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|20|Valid Parentheses|[Python](python/020 Valid Parentheses.py) [Java]()|Easy|| -|42|Trapping Rain Water|[Python](python/042 Trapping Rain Water.py) [Java]()|Hard|| -|71|Simplify Path|[Python](python/071 Simplify Path.py) [Java]()|Medium|| -|84|Largest Rectangle in Histogram|[Python](python/084 Largest Rectangle in Histogram.py) [Java]()|Hard|| -|85|Maximal Rectangle|[Python](python/085 Maximal Rectangle.py) [Java]()|Hard|| -|94|Binary Tree Inorder Traversal|[Python](python/094 Binary Tree Inorder Traversal.py) [Java]()|Medium|| -|103|Binary Tree Zigzag Level Order Traversal|[Python](python/103 Binary Tree Zigzag Level Order Traversal.py) [Java]()|Medium|| -|144|Binary Tree Preorder Traversal|[Python](python/144 Binary Tree Preorder Traversal.py) [Java]()|Medium|| -|145|Binary Tree Postorder Traversal|[Python](python/145 Binary Tree Postorder Traversal.py) [Java]()|Hard|| -|150|Evaluate Reverse Polish Notation|[Python](python/150 Evaluate Reverse Polish Notation.py) [Java]()|Medium|| -|155|Min Stack|[Python](python/155 Min Stack.py) [Java]()|Easy|| -|173|Binary Search Tree Iterator|[Python](python/173 Binary Search Tree Iterator.py) [Java]()|Medium|| -|224|Basic Calculator|[Python](python/224 Basic Calculator.py) [Java]()|Hard|| -|225|Implement Stack using Queues|[Python](python/225 Implement Stack using Queues.py) [Java]()|Easy|| -|232|Implement Queue using Stacks|[Python](python/232 Implement Queue using Stacks.py) [Java]()|Easy|| -|255|Verify Preorder Sequence in Binary Search Tree|[Python](python/255 Verify Preorder Sequence in Binary Search Tree.py) [Java]()|Medium|| -|272|Closest Binary Search Tree Value II|[Python](python/272 Closest Binary Search Tree Value II.py) [Java]()|Hard|| -|316|Remove Duplicate Letters|[Python](python/316 Remove Duplicate Letters.py) [Java]()|Hard|| -|331|Verify Preorder Serialization of a Binary Tree|[Python](python/331 Verify Preorder Serialization of a Binary Tree.py) [Java]()|Medium|| -|341|Flatten Nested List Iterator|[Python](python/341 Flatten Nested List Iterator.py) [Java]()|Medium|| -|385|Mini Parser|[Python](python/385 Mini Parser.py) [Java]()|Medium|| -|394|Decode String|[Python](python/394 Decode String.py) [Java]()|Medium|| -|402|Remove K Digits|[Python](python/402 Remove K Digits.py) [Java]()|Medium|| -|439|Ternary Expression Parser|[Python](python/439 Ternary Expression Parser.py) [Java]()|Medium|| -|456|132 Pattern|[Python](python/456 132 Pattern.py) [Java]()|Medium|| -|496|Next Greater Element I|[Python](python/496 Next Greater Element I.py) [Java]()|Easy|| -|503|Next Greater Element II|[Python](python/503 Next Greater Element II.py) [Java]()|Medium|| +|20|[Valid Parentheses](https://leetcode.com/problems/valid-parentheses)|[Python](./python/020 Valid Parentheses.py) [Java]()|Easy|| +|42|[Trapping Rain Water](https://leetcode.com/problems/trapping-rain-water)|[Python](./python/042 Trapping Rain Water.py) [Java]()|Hard|| +|71|[Simplify Path](https://leetcode.com/problems/simplify-path)|[Python](./python/071 Simplify Path.py) [Java]()|Medium|| +|84|[Largest Rectangle in Histogram](https://leetcode.com/problems/largest-rectangle-in-histogram)|[Python](./python/084 Largest Rectangle in Histogram.py) [Java]()|Hard|| +|85|[Maximal Rectangle](https://leetcode.com/problems/maximal-rectangle)|[Python](./python/085 Maximal Rectangle.py) [Java]()|Hard|| +|94|[Binary Tree Inorder Traversal](https://leetcode.com/problems/binary-tree-inorder-traversal)|[Python](./python/094 Binary Tree Inorder Traversal.py) [Java]()|Medium|| +|103|[Binary Tree Zigzag Level Order Traversal](https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal)|[Python](./python/103 Binary Tree Zigzag Level Order Traversal.py) [Java]()|Medium|| +|144|[Binary Tree Preorder Traversal](https://leetcode.com/problems/binary-tree-preorder-traversal)|[Python](./python/144 Binary Tree Preorder Traversal.py) [Java]()|Medium|| +|145|[Binary Tree Postorder Traversal](https://leetcode.com/problems/binary-tree-postorder-traversal)|[Python](./python/145 Binary Tree Postorder Traversal.py) [Java]()|Hard|| +|150|[Evaluate Reverse Polish Notation](https://leetcode.com/problems/evaluate-reverse-polish-notation)|[Python](./python/150 Evaluate Reverse Polish Notation.py) [Java]()|Medium|| +|155|[Min Stack](https://leetcode.com/problems/min-stack)|[Python](./python/155 Min Stack.py) [Java]()|Easy|| +|173|[Binary Search Tree Iterator](https://leetcode.com/problems/binary-search-tree-iterator)|[Python](./python/173 Binary Search Tree Iterator.py) [Java]()|Medium|| +|224|[Basic Calculator](https://leetcode.com/problems/basic-calculator)|[Python](./python/224 Basic Calculator.py) [Java]()|Hard|| +|225|[Implement Stack using Queues](https://leetcode.com/problems/implement-stack-using-queues)|[Python](./python/225 Implement Stack using Queues.py) [Java]()|Easy|| +|232|[Implement Queue using Stacks](https://leetcode.com/problems/implement-queue-using-stacks)|[Python](./python/232 Implement Queue using Stacks.py) [Java]()|Easy|| +|255|[Verify Preorder Sequence in Binary Search Tree](https://leetcode.com/problems/verify-preorder-sequence-in-binary-search-tree)|[Python](./python/255 Verify Preorder Sequence in Binary Search Tree.py) [Java]()|Medium|| +|272|[Closest Binary Search Tree Value II](https://leetcode.com/problems/closest-binary-search-tree-value-ii)|[Python](./python/272 Closest Binary Search Tree Value II.py) [Java]()|Hard|| +|316|[Remove Duplicate Letters](https://leetcode.com/problems/remove-duplicate-letters)|[Python](./python/316 Remove Duplicate Letters.py) [Java]()|Hard|| +|331|[Verify Preorder Serialization of a Binary Tree](https://leetcode.com/problems/verify-preorder-serialization-of-a-binary-tree)|[Python](./python/331 Verify Preorder Serialization of a Binary Tree.py) [Java]()|Medium|| +|341|[Flatten Nested List Iterator](https://leetcode.com/problems/flatten-nested-list-iterator)|[Python](./python/341 Flatten Nested List Iterator.py) [Java]()|Medium|| +|385|[Mini Parser](https://leetcode.com/problems/mini-parser)|[Python](./python/385 Mini Parser.py) [Java]()|Medium|| +|394|[Decode String](https://leetcode.com/problems/decode-string)|[Python](./python/394 Decode String.py) [Java]()|Medium|| +|402|[Remove K Digits](https://leetcode.com/problems/remove-k-digits)|[Python](./python/402 Remove K Digits.py) [Java]()|Medium|| +|439|[Ternary Expression Parser](https://leetcode.com/problems/ternary-expression-parser)|[Python](./python/439 Ternary Expression Parser.py) [Java]()|Medium|| +|456|[132 Pattern](https://leetcode.com/problems/132-pattern)|[Python](./python/456 132 Pattern.py) [Java]()|Medium|| +|496|[Next Greater Element I](https://leetcode.com/problems/next-greater-element-i)|[Python](./python/496 Next Greater Element I.py) [Java]()|Easy|| +|503|[Next Greater Element II](https://leetcode.com/problems/next-greater-element-ii)|[Python](./python/503 Next Greater Element II.py) [Java]()|Medium|| ## Heap | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|23|Merge k Sorted Lists|[Python](python/023 Merge k Sorted Lists.py) [Java]()|Hard|| -|215|Kth Largest Element in an Array|[Python](python/215 Kth Largest Element in an Array.py) [Java]()|Medium|| -|218|The Skyline Problem|[Python](python/218 The Skyline Problem.py) [Java]()|Hard|| -|239|Sliding Window Maximum|[Python](python/239 Sliding Window Maximum.py) [Java]()|Hard|| -|253|Meeting Rooms II|[Python](python/253 Meeting Rooms II.py) [Java]()|Medium|| -|264|Ugly Number II|[Python](python/264 Ugly Number II.py) [Java]()|Medium|| -|295|Find Median from Data Stream|[Python](python/295 Find Median from Data Stream.py) [Java]()|Hard|| -|313|Super Ugly Number|[Python](python/313 Super Ugly Number.py) [Java]()|Medium|| -|347|Top K Frequent Elements|[Python](python/347 Top K Frequent Elements.py) [Java]()|Medium|| -|355|Design Twitter|[Python](python/355 Design Twitter.py) [Java]()|Medium|| -|358|Rearrange String k Distance Apart|[Python](python/358 Rearrange String k Distance Apart.py) [Java]()|Hard|| -|373|Find K Pairs with Smallest Sums|[Python](python/373 Find K Pairs with Smallest Sums.py) [Java]()|Medium|| -|378|Kth Smallest Element in a Sorted Matrix|[Python](python/378 Kth Smallest Element in a Sorted Matrix.py) [Java]()|Medium|| -|407|Trapping Rain Water II|[Python](python/407 Trapping Rain Water II.py) [Java]()|Hard|| -|451|Sort Characters By Frequency|[Python](python/451 Sort Characters By Frequency.py) [Java]()|Medium|| -|502|IPO|[Python](python/502 IPO.py) [Java]()|Hard|| +|23|[Merge k Sorted Lists](https://leetcode.com/problems/merge-k-sorted-lists)|[Python](./python/023 Merge k Sorted Lists.py) [Java]()|Hard|| +|215|[Kth Largest Element in an Array](https://leetcode.com/problems/kth-largest-element-in-an-array)|[Python](./python/215 Kth Largest Element in an Array.py) [Java]()|Medium|| +|218|[The Skyline Problem](https://leetcode.com/problems/the-skyline-problem)|[Python](./python/218 The Skyline Problem.py) [Java]()|Hard|| +|239|[Sliding Window Maximum](https://leetcode.com/problems/sliding-window-maximum)|[Python](./python/239 Sliding Window Maximum.py) [Java]()|Hard|| +|253|[Meeting Rooms II](https://leetcode.com/problems/meeting-rooms-ii)|[Python](./python/253 Meeting Rooms II.py) [Java]()|Medium|| +|264|[Ugly Number II](https://leetcode.com/problems/ugly-number-ii)|[Python](./python/264 Ugly Number II.py) [Java]()|Medium|| +|295|[Find Median from Data Stream](https://leetcode.com/problems/find-median-from-data-stream)|[Python](./python/295 Find Median from Data Stream.py) [Java]()|Hard|| +|313|[Super Ugly Number](https://leetcode.com/problems/super-ugly-number)|[Python](./python/313 Super Ugly Number.py) [Java]()|Medium|| +|347|[Top K Frequent Elements](https://leetcode.com/problems/top-k-frequent-elements)|[Python](./python/347 Top K Frequent Elements.py) [Java]()|Medium|| +|355|[Design Twitter](https://leetcode.com/problems/design-twitter)|[Python](./python/355 Design Twitter.py) [Java]()|Medium|| +|358|[Rearrange String k Distance Apart](https://leetcode.com/problems/rearrange-string-k-distance-apart)|[Python](./python/358 Rearrange String k Distance Apart.py) [Java]()|Hard|| +|373|[Find K Pairs with Smallest Sums](https://leetcode.com/problems/find-k-pairs-with-smallest-sums)|[Python](./python/373 Find K Pairs with Smallest Sums.py) [Java]()|Medium|| +|378|[Kth Smallest Element in a Sorted Matrix](https://leetcode.com/problems/kth-smallest-element-in-a-sorted-matrix)|[Python](./python/378 Kth Smallest Element in a Sorted Matrix.py) [Java]()|Medium|| +|407|[Trapping Rain Water II](https://leetcode.com/problems/trapping-rain-water-ii)|[Python](./python/407 Trapping Rain Water II.py) [Java]()|Hard|| +|451|[Sort Characters By Frequency](https://leetcode.com/problems/sort-characters-by-frequency)|[Python](./python/451 Sort Characters By Frequency.py) [Java]()|Medium|| +|502|[IPO](https://leetcode.com/problems/ipo)|[Python](./python/502 IPO.py) [Java]()|Hard|| ## Tree | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|94|Binary Tree Inorder Traversal|[Python](python/094 Binary Tree Inorder Traversal.py) [Java]()|Medium|| -|95|Unique Binary Search Trees II|[Python](python/095 Unique Binary Search Trees II.py) [Java]()|Medium|| -|96|Unique Binary Search Trees|[Python](python/096 Unique Binary Search Trees.py) [Java]()|Medium|| -|98|Validate Binary Search Tree|[Python](python/098 Validate Binary Search Tree.py) [Java]()|Medium|| -|99|Recover Binary Search Tree|[Python](python/099 Recover Binary Search Tree.py) [Java]()|Hard|| -|100|Same Tree|[Python](python/100 Same Tree.py) [Java]()|Easy|| -|101|Symmetric Tree|[Python](python/101 Symmetric Tree.py) [Java]()|Easy|| -|102|Binary Tree Level Order Traversal|[Python](python/102 Binary Tree Level Order Traversal.py) [Java]()|Medium|| -|103|Binary Tree Zigzag Level Order Traversal|[Python](python/103 Binary Tree Zigzag Level Order Traversal.py) [Java]()|Medium|| -|104|Maximum Depth of Binary Tree|[Python](python/104 Maximum Depth of Binary Tree.py) [Java]()|Easy|| -|105|Construct Binary Tree from Preorder and Inorder Traversal|[Python](python/105 Construct Binary Tree from Preorder and Inorder Traversal.py) [Java]()|Medium|| -|106|Construct Binary Tree from Inorder and Postorder Traversal|[Python](python/106 Construct Binary Tree from Inorder and Postorder Traversal.py) [Java]()|Medium|| -|107|Binary Tree Level Order Traversal II|[Python](python/107 Binary Tree Level Order Traversal II.py) [Java]()|Easy|| -|108|Convert Sorted Array to Binary Search Tree|[Python](python/108 Convert Sorted Array to Binary Search Tree.py) [Java]()|Easy|| -|110|Balanced Binary Tree|[Python](python/110 Balanced Binary Tree.py) [Java]()|Easy|| -|111|Minimum Depth of Binary Tree|[Python](python/111 Minimum Depth of Binary Tree.py) [Java]()|Easy|| -|112|Path Sum|[Python](python/112 Path Sum.py) [Java]()|Easy|| -|113|Path Sum II|[Python](python/113 Path Sum II.py) [Java]()|Medium|| -|114|Flatten Binary Tree to Linked List|[Python](python/114 Flatten Binary Tree to Linked List.py) [Java]()|Medium|| -|116|Populating Next Right Pointers in Each Node|[Python](python/116 Populating Next Right Pointers in Each Node.py) [Java]()|Medium|| -|117|Populating Next Right Pointers in Each Node II|[Python](python/117 Populating Next Right Pointers in Each Node II.py) [Java]()|Medium|| -|124|Binary Tree Maximum Path Sum|[Python](python/124 Binary Tree Maximum Path Sum.py) [Java]()|Hard|| -|129|Sum Root to Leaf Numbers|[Python](python/129 Sum Root to Leaf Numbers.py) [Java]()|Medium|| -|144|Binary Tree Preorder Traversal|[Python](python/144 Binary Tree Preorder Traversal.py) [Java]()|Medium|| -|145|Binary Tree Postorder Traversal|[Python](python/145 Binary Tree Postorder Traversal.py) [Java]()|Hard|| -|156|Binary Tree Upside Down|[Python](python/156 Binary Tree Upside Down.py) [Java]()|Medium|| -|173|Binary Search Tree Iterator|[Python](python/173 Binary Search Tree Iterator.py) [Java]()|Medium|| -|199|Binary Tree Right Side View|[Python](python/199 Binary Tree Right Side View.py) [Java]()|Medium|| -|222|Count Complete Tree Nodes|[Python](python/222 Count Complete Tree Nodes.py) [Java]()|Medium|| -|226|Invert Binary Tree|[Python](python/226 Invert Binary Tree.py) [Java]()|Easy|| -|230|Kth Smallest Element in a BST|[Python](python/230 Kth Smallest Element in a BST.py) [Java]()|Medium|| -|235|Lowest Common Ancestor of a Binary Search Tree|[Python](python/235 Lowest Common Ancestor of a Binary Search Tree.py) [Java]()|Easy|| -|236|Lowest Common Ancestor of a Binary Tree|[Python](python/236 Lowest Common Ancestor of a Binary Tree.py) [Java]()|Medium|| -|250|Count Univalue Subtrees|[Python](python/250 Count Univalue Subtrees.py) [Java]()|Medium|| -|255|Verify Preorder Sequence in Binary Search Tree|[Python](python/255 Verify Preorder Sequence in Binary Search Tree.py) [Java]()|Medium|| -|257|Binary Tree Paths|[Python](python/257 Binary Tree Paths.py) [Java]()|Easy|| -|270|Closest Binary Search Tree Value|[Python](python/270 Closest Binary Search Tree Value.py) [Java]()|Easy|| -|272|Closest Binary Search Tree Value II|[Python](python/272 Closest Binary Search Tree Value II.py) [Java]()|Hard|| -|285|Inorder Successor in BST|[Python](python/285 Inorder Successor in BST.py) [Java]()|Medium|| -|297|Serialize and Deserialize Binary Tree|[Python](python/297 Serialize and Deserialize Binary Tree.py) [Java]()|Hard|| -|298|Binary Tree Longest Consecutive Sequence|[Python](python/298 Binary Tree Longest Consecutive Sequence.py) [Java]()|Medium|| -|333|Largest BST Subtree|[Python](python/333 Largest BST Subtree.py) [Java]()|Medium|| -|337|House Robber III|[Python](python/337 House Robber III.py) [Java]()|Medium|| -|366|Find Leaves of Binary Tree|[Python](python/366 Find Leaves of Binary Tree.py) [Java]()|Medium|| -|404|Sum of Left Leaves|[Python](python/404 Sum of Left Leaves.py) [Java]()|Easy|| -|437|Path Sum III|[Python](python/437 Path Sum III.py) [Java]()|Easy|| -|449|Serialize and Deserialize BST|[Python](python/449 Serialize and Deserialize BST.py) [Java]()|Medium|| -|450|Delete Node in a BST|[Python](python/450 Delete Node in a BST.py) [Java]()|Medium|| -|501|Find Mode in Binary Search Tree|[Python](python/501 Find Mode in Binary Search Tree.py) [Java]()|Easy|| -|508|Most Frequent Subtree Sum|[Python](python/508 Most Frequent Subtree Sum.py) [Java]()|Medium|| -|513|Find Bottom Left Tree Value|[Python](python/513 Find Bottom Left Tree Value.py) [Java]()|Medium|| -|515|Find Largest Value in Each Tree Row|[Python](python/515 Find Largest Value in Each Tree Row.py) [Java]()|Medium|| -|536|Construct Binary Tree from String|[Python](python/536 Construct Binary Tree from String.py) [Java]()|Medium|| -|538|Convert BST to Greater Tree|[Python](python/538 Convert BST to Greater Tree.py) [Java]()|Medium|| -|543|Diameter of Binary Tree|[Python](python/543 Diameter of Binary Tree.py) [Java]()|Easy|| -|545|Boundary of Binary Tree|[Python](python/545 Boundary of Binary Tree.py) [Java]()|Medium|| -|549|Binary Tree Longest Consecutive Sequence II|[Python](python/549 Binary Tree Longest Consecutive Sequence II.py) [Java]()|Medium|| -|563|Binary Tree Tilt|[Python](python/563 Binary Tree Tilt.py) [Java]()|Easy|| +|94|[Binary Tree Inorder Traversal](https://leetcode.com/problems/binary-tree-inorder-traversal)|[Python](./python/094 Binary Tree Inorder Traversal.py) [Java]()|Medium|| +|95|[Unique Binary Search Trees II](https://leetcode.com/problems/unique-binary-search-trees-ii)|[Python](./python/095 Unique Binary Search Trees II.py) [Java]()|Medium|| +|96|[Unique Binary Search Trees](https://leetcode.com/problems/unique-binary-search-trees)|[Python](./python/096 Unique Binary Search Trees.py) [Java]()|Medium|| +|98|[Validate Binary Search Tree](https://leetcode.com/problems/validate-binary-search-tree)|[Python](./python/098 Validate Binary Search Tree.py) [Java]()|Medium|| +|99|[Recover Binary Search Tree](https://leetcode.com/problems/recover-binary-search-tree)|[Python](./python/099 Recover Binary Search Tree.py) [Java]()|Hard|| +|100|[Same Tree](https://leetcode.com/problems/same-tree)|[Python](./python/100 Same Tree.py) [Java]()|Easy|| +|101|[Symmetric Tree](https://leetcode.com/problems/symmetric-tree)|[Python](./python/101 Symmetric Tree.py) [Java]()|Easy|| +|102|[Binary Tree Level Order Traversal](https://leetcode.com/problems/binary-tree-level-order-traversal)|[Python](./python/102 Binary Tree Level Order Traversal.py) [Java]()|Medium|| +|103|[Binary Tree Zigzag Level Order Traversal](https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal)|[Python](./python/103 Binary Tree Zigzag Level Order Traversal.py) [Java]()|Medium|| +|104|[Maximum Depth of Binary Tree](https://leetcode.com/problems/maximum-depth-of-binary-tree)|[Python](./python/104 Maximum Depth of Binary Tree.py) [Java]()|Easy|| +|105|[Construct Binary Tree from Preorder and Inorder Traversal](https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal)|[Python](./python/105 Construct Binary Tree from Preorder and Inorder Traversal.py) [Java]()|Medium|| +|106|[Construct Binary Tree from Inorder and Postorder Traversal](https://leetcode.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal)|[Python](./python/106 Construct Binary Tree from Inorder and Postorder Traversal.py) [Java]()|Medium|| +|107|[Binary Tree Level Order Traversal II](https://leetcode.com/problems/binary-tree-level-order-traversal-ii)|[Python](./python/107 Binary Tree Level Order Traversal II.py) [Java]()|Easy|| +|108|[Convert Sorted Array to Binary Search Tree](https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree)|[Python](./python/108 Convert Sorted Array to Binary Search Tree.py) [Java]()|Easy|| +|110|[Balanced Binary Tree](https://leetcode.com/problems/balanced-binary-tree)|[Python](./python/110 Balanced Binary Tree.py) [Java]()|Easy|| +|111|[Minimum Depth of Binary Tree](https://leetcode.com/problems/minimum-depth-of-binary-tree)|[Python](./python/111 Minimum Depth of Binary Tree.py) [Java]()|Easy|| +|112|[Path Sum](https://leetcode.com/problems/path-sum)|[Python](./python/112 Path Sum.py) [Java]()|Easy|| +|113|[Path Sum II](https://leetcode.com/problems/path-sum-ii)|[Python](./python/113 Path Sum II.py) [Java]()|Medium|| +|114|[Flatten Binary Tree to Linked List](https://leetcode.com/problems/flatten-binary-tree-to-linked-list)|[Python](./python/114 Flatten Binary Tree to Linked List.py) [Java]()|Medium|| +|116|[Populating Next Right Pointers in Each Node](https://leetcode.com/problems/populating-next-right-pointers-in-each-node)|[Python](./python/116 Populating Next Right Pointers in Each Node.py) [Java]()|Medium|| +|117|[Populating Next Right Pointers in Each Node II](https://leetcode.com/problems/populating-next-right-pointers-in-each-node-ii)|[Python](./python/117 Populating Next Right Pointers in Each Node II.py) [Java]()|Medium|| +|124|[Binary Tree Maximum Path Sum](https://leetcode.com/problems/binary-tree-maximum-path-sum)|[Python](./python/124 Binary Tree Maximum Path Sum.py) [Java]()|Hard|| +|129|[Sum Root to Leaf Numbers](https://leetcode.com/problems/sum-root-to-leaf-numbers)|[Python](./python/129 Sum Root to Leaf Numbers.py) [Java]()|Medium|| +|144|[Binary Tree Preorder Traversal](https://leetcode.com/problems/binary-tree-preorder-traversal)|[Python](./python/144 Binary Tree Preorder Traversal.py) [Java]()|Medium|| +|145|[Binary Tree Postorder Traversal](https://leetcode.com/problems/binary-tree-postorder-traversal)|[Python](./python/145 Binary Tree Postorder Traversal.py) [Java]()|Hard|| +|156|[Binary Tree Upside Down](https://leetcode.com/problems/binary-tree-upside-down)|[Python](./python/156 Binary Tree Upside Down.py) [Java]()|Medium|| +|173|[Binary Search Tree Iterator](https://leetcode.com/problems/binary-search-tree-iterator)|[Python](./python/173 Binary Search Tree Iterator.py) [Java]()|Medium|| +|199|[Binary Tree Right Side View](https://leetcode.com/problems/binary-tree-right-side-view)|[Python](./python/199 Binary Tree Right Side View.py) [Java]()|Medium|| +|222|[Count Complete Tree Nodes](https://leetcode.com/problems/count-complete-tree-nodes)|[Python](./python/222 Count Complete Tree Nodes.py) [Java]()|Medium|| +|226|[Invert Binary Tree](https://leetcode.com/problems/invert-binary-tree)|[Python](./python/226 Invert Binary Tree.py) [Java]()|Easy|| +|230|[Kth Smallest Element in a BST](https://leetcode.com/problems/kth-smallest-element-in-a-bst)|[Python](./python/230 Kth Smallest Element in a BST.py) [Java]()|Medium|| +|235|[Lowest Common Ancestor of a Binary Search Tree](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree)|[Python](./python/235 Lowest Common Ancestor of a Binary Search Tree.py) [Java]()|Easy|| +|236|[Lowest Common Ancestor of a Binary Tree](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree)|[Python](./python/236 Lowest Common Ancestor of a Binary Tree.py) [Java]()|Medium|| +|250|[Count Univalue Subtrees](https://leetcode.com/problems/count-univalue-subtrees)|[Python](./python/250 Count Univalue Subtrees.py) [Java]()|Medium|| +|255|[Verify Preorder Sequence in Binary Search Tree](https://leetcode.com/problems/verify-preorder-sequence-in-binary-search-tree)|[Python](./python/255 Verify Preorder Sequence in Binary Search Tree.py) [Java]()|Medium|| +|257|[Binary Tree Paths](https://leetcode.com/problems/binary-tree-paths)|[Python](./python/257 Binary Tree Paths.py) [Java]()|Easy|| +|270|[Closest Binary Search Tree Value](https://leetcode.com/problems/closest-binary-search-tree-value)|[Python](./python/270 Closest Binary Search Tree Value.py) [Java]()|Easy|| +|272|[Closest Binary Search Tree Value II](https://leetcode.com/problems/closest-binary-search-tree-value-ii)|[Python](./python/272 Closest Binary Search Tree Value II.py) [Java]()|Hard|| +|285|[Inorder Successor in BST](https://leetcode.com/problems/inorder-successor-in-bst)|[Python](./python/285 Inorder Successor in BST.py) [Java]()|Medium|| +|297|[Serialize and Deserialize Binary Tree](https://leetcode.com/problems/serialize-and-deserialize-binary-tree)|[Python](./python/297 Serialize and Deserialize Binary Tree.py) [Java]()|Hard|| +|298|[Binary Tree Longest Consecutive Sequence](https://leetcode.com/problems/binary-tree-longest-consecutive-sequence)|[Python](./python/298 Binary Tree Longest Consecutive Sequence.py) [Java]()|Medium|| +|333|[Largest BST Subtree](https://leetcode.com/problems/largest-bst-subtree)|[Python](./python/333 Largest BST Subtree.py) [Java]()|Medium|| +|337|[House Robber III](https://leetcode.com/problems/house-robber-iii)|[Python](./python/337 House Robber III.py) [Java]()|Medium|| +|366|[Find Leaves of Binary Tree](https://leetcode.com/problems/find-leaves-of-binary-tree)|[Python](./python/366 Find Leaves of Binary Tree.py) [Java]()|Medium|| +|404|[Sum of Left Leaves](https://leetcode.com/problems/sum-of-left-leaves)|[Python](./python/404 Sum of Left Leaves.py) [Java]()|Easy|| +|437|[Path Sum III](https://leetcode.com/problems/path-sum-iii)|[Python](./python/437 Path Sum III.py) [Java]()|Easy|| +|449|[Serialize and Deserialize BST](https://leetcode.com/problems/serialize-and-deserialize-bst)|[Python](./python/449 Serialize and Deserialize BST.py) [Java]()|Medium|| +|450|[Delete Node in a BST](https://leetcode.com/problems/delete-node-in-a-bst)|[Python](./python/450 Delete Node in a BST.py) [Java]()|Medium|| +|501|[Find Mode in Binary Search Tree](https://leetcode.com/problems/find-mode-in-binary-search-tree)|[Python](./python/501 Find Mode in Binary Search Tree.py) [Java]()|Easy|| +|508|[Most Frequent Subtree Sum](https://leetcode.com/problems/most-frequent-subtree-sum)|[Python](./python/508 Most Frequent Subtree Sum.py) [Java]()|Medium|| +|513|[Find Bottom Left Tree Value](https://leetcode.com/problems/find-bottom-left-tree-value)|[Python](./python/513 Find Bottom Left Tree Value.py) [Java]()|Medium|| +|515|[Find Largest Value in Each Tree Row](https://leetcode.com/problems/find-largest-value-in-each-tree-row)|[Python](./python/515 Find Largest Value in Each Tree Row.py) [Java]()|Medium|| +|536|[Construct Binary Tree from String](https://leetcode.com/problems/construct-binary-tree-from-string)|[Python](./python/536 Construct Binary Tree from String.py) [Java]()|Medium|| +|538|[Convert BST to Greater Tree](https://leetcode.com/problems/convert-bst-to-greater-tree)|[Python](./python/538 Convert BST to Greater Tree.py) [Java]()|Medium|| +|543|[Diameter of Binary Tree](https://leetcode.com/problems/diameter-of-binary-tree)|[Python](./python/543 Diameter of Binary Tree.py) [Java]()|Easy|| +|545|[Boundary of Binary Tree](https://leetcode.com/problems/boundary-of-binary-tree)|[Python](./python/545 Boundary of Binary Tree.py) [Java]()|Medium|| +|549|[Binary Tree Longest Consecutive Sequence II](https://leetcode.com/problems/binary-tree-longest-consecutive-sequence-ii)|[Python](./python/549 Binary Tree Longest Consecutive Sequence II.py) [Java]()|Medium|| +|563|[Binary Tree Tilt](https://leetcode.com/problems/binary-tree-tilt)|[Python](./python/563 Binary Tree Tilt.py) [Java]()|Easy|| ## Depth-first Search | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|98|Validate Binary Search Tree|[Python](python/098 Validate Binary Search Tree.py) [Java]()|Medium|| -|99|Recover Binary Search Tree|[Python](python/099 Recover Binary Search Tree.py) [Java]()|Hard|| -|100|Same Tree|[Python](python/100 Same Tree.py) [Java]()|Easy|| -|101|Symmetric Tree|[Python](python/101 Symmetric Tree.py) [Java]()|Easy|| -|104|Maximum Depth of Binary Tree|[Python](python/104 Maximum Depth of Binary Tree.py) [Java]()|Easy|| -|105|Construct Binary Tree from Preorder and Inorder Traversal|[Python](python/105 Construct Binary Tree from Preorder and Inorder Traversal.py) [Java]()|Medium|| -|106|Construct Binary Tree from Inorder and Postorder Traversal|[Python](python/106 Construct Binary Tree from Inorder and Postorder Traversal.py) [Java]()|Medium|| -|108|Convert Sorted Array to Binary Search Tree|[Python](python/108 Convert Sorted Array to Binary Search Tree.py) [Java]()|Easy|| -|109|Convert Sorted List to Binary Search Tree|[Python](python/109 Convert Sorted List to Binary Search Tree.py) [Java]()|Medium|| -|110|Balanced Binary Tree|[Python](python/110 Balanced Binary Tree.py) [Java]()|Easy|| -|111|Minimum Depth of Binary Tree|[Python](python/111 Minimum Depth of Binary Tree.py) [Java]()|Easy|| -|112|Path Sum|[Python](python/112 Path Sum.py) [Java]()|Easy|| -|113|Path Sum II|[Python](python/113 Path Sum II.py) [Java]()|Medium|| -|114|Flatten Binary Tree to Linked List|[Python](python/114 Flatten Binary Tree to Linked List.py) [Java]()|Medium|| -|116|Populating Next Right Pointers in Each Node|[Python](python/116 Populating Next Right Pointers in Each Node.py) [Java]()|Medium|| -|117|Populating Next Right Pointers in Each Node II|[Python](python/117 Populating Next Right Pointers in Each Node II.py) [Java]()|Medium|| -|124|Binary Tree Maximum Path Sum|[Python](python/124 Binary Tree Maximum Path Sum.py) [Java]()|Hard|| -|129|Sum Root to Leaf Numbers|[Python](python/129 Sum Root to Leaf Numbers.py) [Java]()|Medium|| -|133|Clone Graph|[Python](python/133 Clone Graph.py) [Java]()|Medium|| -|199|Binary Tree Right Side View|[Python](python/199 Binary Tree Right Side View.py) [Java]()|Medium|| -|200|Number of Islands|[Python](python/200 Number of Islands.py) [Java]()|Medium|| -|207|Course Schedule|[Python](python/207 Course Schedule.py) [Java]()|Medium|| -|210|Course Schedule II|[Python](python/210 Course Schedule II.py) [Java]()|Medium|| -|257|Binary Tree Paths|[Python](python/257 Binary Tree Paths.py) [Java]()|Easy|| -|261|Graph Valid Tree|[Python](python/261 Graph Valid Tree.py) [Java]()|Medium|| -|301|Remove Invalid Parentheses|[Python](python/301 Remove Invalid Parentheses.py) [Java]()|Hard|| -|323|Number of Connected Components in an Undirected Graph|[Python](python/323 Number of Connected Components in an Undirected Graph.py) [Java]()|Medium|| -|329|Longest Increasing Path in a Matrix|[Python](python/329 Longest Increasing Path in a Matrix.py) [Java]()|Hard|| -|332|Reconstruct Itinerary|[Python](python/332 Reconstruct Itinerary.py) [Java]()|Medium|| -|337|House Robber III|[Python](python/337 House Robber III.py) [Java]()|Medium|| -|339|Nested List Weight Sum|[Python](python/339 Nested List Weight Sum.py) [Java]()|Easy|| -|364|Nested List Weight Sum II|[Python](python/364 Nested List Weight Sum II.py) [Java]()|Medium|| -|366|Find Leaves of Binary Tree|[Python](python/366 Find Leaves of Binary Tree.py) [Java]()|Medium|| -|394|Decode String|[Python](python/394 Decode String.py) [Java]()|Medium|| -|417|Pacific Atlantic Water Flow|[Python](python/417 Pacific Atlantic Water Flow.py) [Java]()|Medium|| -|439|Ternary Expression Parser|[Python](python/439 Ternary Expression Parser.py) [Java]()|Medium|| -|472|Concatenated Words|[Python](python/472 Concatenated Words.py) [Java]()|Hard|| -|473|Matchsticks to Square|[Python](python/473 Matchsticks to Square.py) [Java]()|Medium|| -|488|Zuma Game|[Python](python/488 Zuma Game.py) [Java]()|Hard|| -|490|The Maze|[Python](python/490 The Maze.py) [Java]()|Medium|| -|491|Increasing Subsequences|[Python](python/491 Increasing Subsequences.py) [Java]()|Medium|| -|494|Target Sum|[Python](python/494 Target Sum.py) [Java]()|Medium|| -|499|The Maze III|[Python](python/499 The Maze III.py) [Java]()|Hard|| -|505|The Maze II|[Python](python/505 The Maze II.py) [Java]()|Medium|| -|513|Find Bottom Left Tree Value|[Python](python/513 Find Bottom Left Tree Value.py) [Java]()|Medium|| -|514|Freedom Trail|[Python](python/514 Freedom Trail.py) [Java]()|Hard|| -|515|Find Largest Value in Each Tree Row|[Python](python/515 Find Largest Value in Each Tree Row.py) [Java]()|Medium|| -|529|Minesweeper|[Python](python/529 Minesweeper.py) [Java]()|Medium|| -|531|Lonely Pixel I|[Python](python/531 Lonely Pixel I.py) [Java]()|Medium|| -|533|Lonely Pixel II|[Python](python/533 Lonely Pixel II.py) [Java]()|Medium|| -|542|01 Matrix|[Python](python/542 01 Matrix.py) [Java]()|Medium|| -|546|Remove Boxes|[Python](python/546 Remove Boxes.py) [Java]()|Hard|| -|547|Friend Circles|[Python](python/547 Friend Circles.py) [Java]()|Medium|| +|98|[Validate Binary Search Tree](https://leetcode.com/problems/validate-binary-search-tree)|[Python](./python/098 Validate Binary Search Tree.py) [Java]()|Medium|| +|99|[Recover Binary Search Tree](https://leetcode.com/problems/recover-binary-search-tree)|[Python](./python/099 Recover Binary Search Tree.py) [Java]()|Hard|| +|100|[Same Tree](https://leetcode.com/problems/same-tree)|[Python](./python/100 Same Tree.py) [Java]()|Easy|| +|101|[Symmetric Tree](https://leetcode.com/problems/symmetric-tree)|[Python](./python/101 Symmetric Tree.py) [Java]()|Easy|| +|104|[Maximum Depth of Binary Tree](https://leetcode.com/problems/maximum-depth-of-binary-tree)|[Python](./python/104 Maximum Depth of Binary Tree.py) [Java]()|Easy|| +|105|[Construct Binary Tree from Preorder and Inorder Traversal](https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal)|[Python](./python/105 Construct Binary Tree from Preorder and Inorder Traversal.py) [Java]()|Medium|| +|106|[Construct Binary Tree from Inorder and Postorder Traversal](https://leetcode.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal)|[Python](./python/106 Construct Binary Tree from Inorder and Postorder Traversal.py) [Java]()|Medium|| +|108|[Convert Sorted Array to Binary Search Tree](https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree)|[Python](./python/108 Convert Sorted Array to Binary Search Tree.py) [Java]()|Easy|| +|109|[Convert Sorted List to Binary Search Tree](https://leetcode.com/problems/convert-sorted-list-to-binary-search-tree)|[Python](./python/109 Convert Sorted List to Binary Search Tree.py) [Java]()|Medium|| +|110|[Balanced Binary Tree](https://leetcode.com/problems/balanced-binary-tree)|[Python](./python/110 Balanced Binary Tree.py) [Java]()|Easy|| +|111|[Minimum Depth of Binary Tree](https://leetcode.com/problems/minimum-depth-of-binary-tree)|[Python](./python/111 Minimum Depth of Binary Tree.py) [Java]()|Easy|| +|112|[Path Sum](https://leetcode.com/problems/path-sum)|[Python](./python/112 Path Sum.py) [Java]()|Easy|| +|113|[Path Sum II](https://leetcode.com/problems/path-sum-ii)|[Python](./python/113 Path Sum II.py) [Java]()|Medium|| +|114|[Flatten Binary Tree to Linked List](https://leetcode.com/problems/flatten-binary-tree-to-linked-list)|[Python](./python/114 Flatten Binary Tree to Linked List.py) [Java]()|Medium|| +|116|[Populating Next Right Pointers in Each Node](https://leetcode.com/problems/populating-next-right-pointers-in-each-node)|[Python](./python/116 Populating Next Right Pointers in Each Node.py) [Java]()|Medium|| +|117|[Populating Next Right Pointers in Each Node II](https://leetcode.com/problems/populating-next-right-pointers-in-each-node-ii)|[Python](./python/117 Populating Next Right Pointers in Each Node II.py) [Java]()|Medium|| +|124|[Binary Tree Maximum Path Sum](https://leetcode.com/problems/binary-tree-maximum-path-sum)|[Python](./python/124 Binary Tree Maximum Path Sum.py) [Java]()|Hard|| +|129|[Sum Root to Leaf Numbers](https://leetcode.com/problems/sum-root-to-leaf-numbers)|[Python](./python/129 Sum Root to Leaf Numbers.py) [Java]()|Medium|| +|133|[Clone Graph](https://leetcode.com/problems/clone-graph)|[Python](./python/133 Clone Graph.py) [Java]()|Medium|| +|199|[Binary Tree Right Side View](https://leetcode.com/problems/binary-tree-right-side-view)|[Python](./python/199 Binary Tree Right Side View.py) [Java]()|Medium|| +|200|[Number of Islands](https://leetcode.com/problems/number-of-islands)|[Python](./python/200 Number of Islands.py) [Java]()|Medium|| +|207|[Course Schedule](https://leetcode.com/problems/course-schedule)|[Python](./python/207 Course Schedule.py) [Java]()|Medium|| +|210|[Course Schedule II](https://leetcode.com/problems/course-schedule-ii)|[Python](./python/210 Course Schedule II.py) [Java]()|Medium|| +|257|[Binary Tree Paths](https://leetcode.com/problems/binary-tree-paths)|[Python](./python/257 Binary Tree Paths.py) [Java]()|Easy|| +|261|[Graph Valid Tree](https://leetcode.com/problems/graph-valid-tree)|[Python](./python/261 Graph Valid Tree.py) [Java]()|Medium|| +|301|[Remove Invalid Parentheses](https://leetcode.com/problems/remove-invalid-parentheses)|[Python](./python/301 Remove Invalid Parentheses.py) [Java]()|Hard|| +|323|[Number of Connected Components in an Undirected Graph](https://leetcode.com/problems/number-of-connected-components-in-an-undirected-graph)|[Python](./python/323 Number of Connected Components in an Undirected Graph.py) [Java]()|Medium|| +|329|[Longest Increasing Path in a Matrix](https://leetcode.com/problems/longest-increasing-path-in-a-matrix)|[Python](./python/329 Longest Increasing Path in a Matrix.py) [Java]()|Hard|| +|332|[Reconstruct Itinerary](https://leetcode.com/problems/reconstruct-itinerary)|[Python](./python/332 Reconstruct Itinerary.py) [Java]()|Medium|| +|337|[House Robber III](https://leetcode.com/problems/house-robber-iii)|[Python](./python/337 House Robber III.py) [Java]()|Medium|| +|339|[Nested List Weight Sum](https://leetcode.com/problems/nested-list-weight-sum)|[Python](./python/339 Nested List Weight Sum.py) [Java]()|Easy|| +|364|[Nested List Weight Sum II](https://leetcode.com/problems/nested-list-weight-sum-ii)|[Python](./python/364 Nested List Weight Sum II.py) [Java]()|Medium|| +|366|[Find Leaves of Binary Tree](https://leetcode.com/problems/find-leaves-of-binary-tree)|[Python](./python/366 Find Leaves of Binary Tree.py) [Java]()|Medium|| +|394|[Decode String](https://leetcode.com/problems/decode-string)|[Python](./python/394 Decode String.py) [Java]()|Medium|| +|417|[Pacific Atlantic Water Flow](https://leetcode.com/problems/pacific-atlantic-water-flow)|[Python](./python/417 Pacific Atlantic Water Flow.py) [Java]()|Medium|| +|439|[Ternary Expression Parser](https://leetcode.com/problems/ternary-expression-parser)|[Python](./python/439 Ternary Expression Parser.py) [Java]()|Medium|| +|472|[Concatenated Words](https://leetcode.com/problems/concatenated-words)|[Python](./python/472 Concatenated Words.py) [Java]()|Hard|| +|473|[Matchsticks to Square](https://leetcode.com/problems/matchsticks-to-square)|[Python](./python/473 Matchsticks to Square.py) [Java]()|Medium|| +|488|[Zuma Game](https://leetcode.com/problems/zuma-game)|[Python](./python/488 Zuma Game.py) [Java]()|Hard|| +|490|[The Maze](https://leetcode.com/problems/the-maze)|[Python](./python/490 The Maze.py) [Java]()|Medium|| +|491|[Increasing Subsequences](https://leetcode.com/problems/increasing-subsequences)|[Python](./python/491 Increasing Subsequences.py) [Java]()|Medium|| +|494|[Target Sum](https://leetcode.com/problems/target-sum)|[Python](./python/494 Target Sum.py) [Java]()|Medium|| +|499|[The Maze III](https://leetcode.com/problems/the-maze-iii)|[Python](./python/499 The Maze III.py) [Java]()|Hard|| +|505|[The Maze II](https://leetcode.com/problems/the-maze-ii)|[Python](./python/505 The Maze II.py) [Java]()|Medium|| +|513|[Find Bottom Left Tree Value](https://leetcode.com/problems/find-bottom-left-tree-value)|[Python](./python/513 Find Bottom Left Tree Value.py) [Java]()|Medium|| +|514|[Freedom Trail](https://leetcode.com/problems/freedom-trail)|[Python](./python/514 Freedom Trail.py) [Java]()|Hard|| +|515|[Find Largest Value in Each Tree Row](https://leetcode.com/problems/find-largest-value-in-each-tree-row)|[Python](./python/515 Find Largest Value in Each Tree Row.py) [Java]()|Medium|| +|529|[Minesweeper](https://leetcode.com/problems/minesweeper)|[Python](./python/529 Minesweeper.py) [Java]()|Medium|| +|531|[Lonely Pixel I](https://leetcode.com/problems/lonely-pixel-i)|[Python](./python/531 Lonely Pixel I.py) [Java]()|Medium|| +|533|[Lonely Pixel II](https://leetcode.com/problems/lonely-pixel-ii)|[Python](./python/533 Lonely Pixel II.py) [Java]()|Medium|| +|542|[01 Matrix](https://leetcode.com/problems/01-matrix)|[Python](./python/542 01 Matrix.py) [Java]()|Medium|| +|546|[Remove Boxes](https://leetcode.com/problems/remove-boxes)|[Python](./python/546 Remove Boxes.py) [Java]()|Hard|| +|547|[Friend Circles](https://leetcode.com/problems/friend-circles)|[Python](./python/547 Friend Circles.py) [Java]()|Medium|| ## Breadth-first Search | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|101|Symmetric Tree|[Python](python/101 Symmetric Tree.py) [Java]()|Easy|| -|102|Binary Tree Level Order Traversal|[Python](python/102 Binary Tree Level Order Traversal.py) [Java]()|Medium|| -|103|Binary Tree Zigzag Level Order Traversal|[Python](python/103 Binary Tree Zigzag Level Order Traversal.py) [Java]()|Medium|| -|107|Binary Tree Level Order Traversal II|[Python](python/107 Binary Tree Level Order Traversal II.py) [Java]()|Easy|| -|111|Minimum Depth of Binary Tree|[Python](python/111 Minimum Depth of Binary Tree.py) [Java]()|Easy|| -|126|Word Ladder II|[Python](python/126 Word Ladder II.py) [Java]()|Hard|| -|130|Surrounded Regions|[Python](python/130 Surrounded Regions.py) [Java]()|Medium|| -|133|Clone Graph|[Python](python/133 Clone Graph.py) [Java]()|Medium|| -|199|Binary Tree Right Side View|[Python](python/199 Binary Tree Right Side View.py) [Java]()|Medium|| -|200|Number of Islands|[Python](python/200 Number of Islands.py) [Java]()|Medium|| -|207|Course Schedule|[Python](python/207 Course Schedule.py) [Java]()|Medium|| -|210|Course Schedule II|[Python](python/210 Course Schedule II.py) [Java]()|Medium|| -|261|Graph Valid Tree|[Python](python/261 Graph Valid Tree.py) [Java]()|Medium|| -|279|Perfect Squares|[Python](python/279 Perfect Squares.py) [Java]()|Medium|| -|286|Walls and Gates|[Python](python/286 Walls and Gates.py) [Java]()|Medium|| -|301|Remove Invalid Parentheses|[Python](python/301 Remove Invalid Parentheses.py) [Java]()|Hard|| -|310|Minimum Height Trees|[Python](python/310 Minimum Height Trees.py) [Java]()|Medium|| -|317|Shortest Distance from All Buildings|[Python](python/317 Shortest Distance from All Buildings.py) [Java]()|Hard|| -|323|Number of Connected Components in an Undirected Graph|[Python](python/323 Number of Connected Components in an Undirected Graph.py) [Java]()|Medium|| -|407|Trapping Rain Water II|[Python](python/407 Trapping Rain Water II.py) [Java]()|Hard|| -|417|Pacific Atlantic Water Flow|[Python](python/417 Pacific Atlantic Water Flow.py) [Java]()|Medium|| -|490|The Maze|[Python](python/490 The Maze.py) [Java]()|Medium|| -|499|The Maze III|[Python](python/499 The Maze III.py) [Java]()|Hard|| -|505|The Maze II|[Python](python/505 The Maze II.py) [Java]()|Medium|| -|513|Find Bottom Left Tree Value|[Python](python/513 Find Bottom Left Tree Value.py) [Java]()|Medium|| -|515|Find Largest Value in Each Tree Row|[Python](python/515 Find Largest Value in Each Tree Row.py) [Java]()|Medium|| -|529|Minesweeper|[Python](python/529 Minesweeper.py) [Java]()|Medium|| -|542|01 Matrix|[Python](python/542 01 Matrix.py) [Java]()|Medium|| +|101|[Symmetric Tree](https://leetcode.com/problems/symmetric-tree)|[Python](./python/101 Symmetric Tree.py) [Java]()|Easy|| +|102|[Binary Tree Level Order Traversal](https://leetcode.com/problems/binary-tree-level-order-traversal)|[Python](./python/102 Binary Tree Level Order Traversal.py) [Java]()|Medium|| +|103|[Binary Tree Zigzag Level Order Traversal](https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal)|[Python](./python/103 Binary Tree Zigzag Level Order Traversal.py) [Java]()|Medium|| +|107|[Binary Tree Level Order Traversal II](https://leetcode.com/problems/binary-tree-level-order-traversal-ii)|[Python](./python/107 Binary Tree Level Order Traversal II.py) [Java]()|Easy|| +|111|[Minimum Depth of Binary Tree](https://leetcode.com/problems/minimum-depth-of-binary-tree)|[Python](./python/111 Minimum Depth of Binary Tree.py) [Java]()|Easy|| +|126|[Word Ladder II](https://leetcode.com/problems/word-ladder-ii)|[Python](./python/126 Word Ladder II.py) [Java]()|Hard|| +|130|[Surrounded Regions](https://leetcode.com/problems/surrounded-regions)|[Python](./python/130 Surrounded Regions.py) [Java]()|Medium|| +|133|[Clone Graph](https://leetcode.com/problems/clone-graph)|[Python](./python/133 Clone Graph.py) [Java]()|Medium|| +|199|[Binary Tree Right Side View](https://leetcode.com/problems/binary-tree-right-side-view)|[Python](./python/199 Binary Tree Right Side View.py) [Java]()|Medium|| +|200|[Number of Islands](https://leetcode.com/problems/number-of-islands)|[Python](./python/200 Number of Islands.py) [Java]()|Medium|| +|207|[Course Schedule](https://leetcode.com/problems/course-schedule)|[Python](./python/207 Course Schedule.py) [Java]()|Medium|| +|210|[Course Schedule II](https://leetcode.com/problems/course-schedule-ii)|[Python](./python/210 Course Schedule II.py) [Java]()|Medium|| +|261|[Graph Valid Tree](https://leetcode.com/problems/graph-valid-tree)|[Python](./python/261 Graph Valid Tree.py) [Java]()|Medium|| +|279|[Perfect Squares](https://leetcode.com/problems/perfect-squares)|[Python](./python/279 Perfect Squares.py) [Java]()|Medium|| +|286|[Walls and Gates](https://leetcode.com/problems/walls-and-gates)|[Python](./python/286 Walls and Gates.py) [Java]()|Medium|| +|301|[Remove Invalid Parentheses](https://leetcode.com/problems/remove-invalid-parentheses)|[Python](./python/301 Remove Invalid Parentheses.py) [Java]()|Hard|| +|310|[Minimum Height Trees](https://leetcode.com/problems/minimum-height-trees)|[Python](./python/310 Minimum Height Trees.py) [Java]()|Medium|| +|317|[Shortest Distance from All Buildings](https://leetcode.com/problems/shortest-distance-from-all-buildings)|[Python](./python/317 Shortest Distance from All Buildings.py) [Java]()|Hard|| +|323|[Number of Connected Components in an Undirected Graph](https://leetcode.com/problems/number-of-connected-components-in-an-undirected-graph)|[Python](./python/323 Number of Connected Components in an Undirected Graph.py) [Java]()|Medium|| +|407|[Trapping Rain Water II](https://leetcode.com/problems/trapping-rain-water-ii)|[Python](./python/407 Trapping Rain Water II.py) [Java]()|Hard|| +|417|[Pacific Atlantic Water Flow](https://leetcode.com/problems/pacific-atlantic-water-flow)|[Python](./python/417 Pacific Atlantic Water Flow.py) [Java]()|Medium|| +|490|[The Maze](https://leetcode.com/problems/the-maze)|[Python](./python/490 The Maze.py) [Java]()|Medium|| +|499|[The Maze III](https://leetcode.com/problems/the-maze-iii)|[Python](./python/499 The Maze III.py) [Java]()|Hard|| +|505|[The Maze II](https://leetcode.com/problems/the-maze-ii)|[Python](./python/505 The Maze II.py) [Java]()|Medium|| +|513|[Find Bottom Left Tree Value](https://leetcode.com/problems/find-bottom-left-tree-value)|[Python](./python/513 Find Bottom Left Tree Value.py) [Java]()|Medium|| +|515|[Find Largest Value in Each Tree Row](https://leetcode.com/problems/find-largest-value-in-each-tree-row)|[Python](./python/515 Find Largest Value in Each Tree Row.py) [Java]()|Medium|| +|529|[Minesweeper](https://leetcode.com/problems/minesweeper)|[Python](./python/529 Minesweeper.py) [Java]()|Medium|| +|542|[01 Matrix](https://leetcode.com/problems/01-matrix)|[Python](./python/542 01 Matrix.py) [Java]()|Medium|| ## Union Find | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|128|Longest Consecutive Sequence|[Python](python/128 Longest Consecutive Sequence.py) [Java]()|Hard|| -|130|Surrounded Regions|[Python](python/130 Surrounded Regions.py) [Java]()|Medium|| -|200|Number of Islands|[Python](python/200 Number of Islands.py) [Java]()|Medium|| -|261|Graph Valid Tree|[Python](python/261 Graph Valid Tree.py) [Java]()|Medium|| -|305|Number of Islands II|[Python](python/305 Number of Islands II.py) [Java]()|Hard|| -|323|Number of Connected Components in an Undirected Graph|[Python](python/323 Number of Connected Components in an Undirected Graph.py) [Java]()|Medium|| -|547|Friend Circles|[Python](python/547 Friend Circles.py) [Java]()|Medium|| +|128|[Longest Consecutive Sequence](https://leetcode.com/problems/longest-consecutive-sequence)|[Python](./python/128 Longest Consecutive Sequence.py) [Java]()|Hard|| +|130|[Surrounded Regions](https://leetcode.com/problems/surrounded-regions)|[Python](./python/130 Surrounded Regions.py) [Java]()|Medium|| +|200|[Number of Islands](https://leetcode.com/problems/number-of-islands)|[Python](./python/200 Number of Islands.py) [Java]()|Medium|| +|261|[Graph Valid Tree](https://leetcode.com/problems/graph-valid-tree)|[Python](./python/261 Graph Valid Tree.py) [Java]()|Medium|| +|305|[Number of Islands II](https://leetcode.com/problems/number-of-islands-ii)|[Python](./python/305 Number of Islands II.py) [Java]()|Hard|| +|323|[Number of Connected Components in an Undirected Graph](https://leetcode.com/problems/number-of-connected-components-in-an-undirected-graph)|[Python](./python/323 Number of Connected Components in an Undirected Graph.py) [Java]()|Medium|| +|547|[Friend Circles](https://leetcode.com/problems/friend-circles)|[Python](./python/547 Friend Circles.py) [Java]()|Medium|| ## Graph | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|133|Clone Graph|[Python](python/133 Clone Graph.py) [Java]()|Medium|| -|207|Course Schedule|[Python](python/207 Course Schedule.py) [Java]()|Medium|| -|210|Course Schedule II|[Python](python/210 Course Schedule II.py) [Java]()|Medium|| -|261|Graph Valid Tree|[Python](python/261 Graph Valid Tree.py) [Java]()|Medium|| -|269|Alien Dictionary|[Python](python/269 Alien Dictionary.py) [Java]()|Hard|| -|310|Minimum Height Trees|[Python](python/310 Minimum Height Trees.py) [Java]()|Medium|| -|323|Number of Connected Components in an Undirected Graph|[Python](python/323 Number of Connected Components in an Undirected Graph.py) [Java]()|Medium|| -|332|Reconstruct Itinerary|[Python](python/332 Reconstruct Itinerary.py) [Java]()|Medium|| -|399|Evaluate Division|[Python](python/399 Evaluate Division.py) [Java]()|Medium|| -|444|Sequence Reconstruction|[Python](python/444 Sequence Reconstruction.py) [Java]()|Medium|| +|133|[Clone Graph](https://leetcode.com/problems/clone-graph)|[Python](./python/133 Clone Graph.py) [Java]()|Medium|| +|207|[Course Schedule](https://leetcode.com/problems/course-schedule)|[Python](./python/207 Course Schedule.py) [Java]()|Medium|| +|210|[Course Schedule II](https://leetcode.com/problems/course-schedule-ii)|[Python](./python/210 Course Schedule II.py) [Java]()|Medium|| +|261|[Graph Valid Tree](https://leetcode.com/problems/graph-valid-tree)|[Python](./python/261 Graph Valid Tree.py) [Java]()|Medium|| +|269|[Alien Dictionary](https://leetcode.com/problems/alien-dictionary)|[Python](./python/269 Alien Dictionary.py) [Java]()|Hard|| +|310|[Minimum Height Trees](https://leetcode.com/problems/minimum-height-trees)|[Python](./python/310 Minimum Height Trees.py) [Java]()|Medium|| +|323|[Number of Connected Components in an Undirected Graph](https://leetcode.com/problems/number-of-connected-components-in-an-undirected-graph)|[Python](./python/323 Number of Connected Components in an Undirected Graph.py) [Java]()|Medium|| +|332|[Reconstruct Itinerary](https://leetcode.com/problems/reconstruct-itinerary)|[Python](./python/332 Reconstruct Itinerary.py) [Java]()|Medium|| +|399|[Evaluate Division](https://leetcode.com/problems/evaluate-division)|[Python](./python/399 Evaluate Division.py) [Java]()|Medium|| +|444|[Sequence Reconstruction](https://leetcode.com/problems/sequence-reconstruction)|[Python](./python/444 Sequence Reconstruction.py) [Java]()|Medium|| ## Design | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|146|LRU Cache|[Python](python/146 LRU Cache.py) [Java]()|Hard|| -|155|Min Stack|[Python](python/155 Min Stack.py) [Java]()|Easy|| -|170|Two Sum III - Data structure design|[Python](python/170 Two Sum III - Data structure design.py) [Java]()|Easy|| -|173|Binary Search Tree Iterator|[Python](python/173 Binary Search Tree Iterator.py) [Java]()|Medium|| -|208|Implement Trie (Prefix Tree)|[Python](python/208 Implement Trie (Prefix Tree).py) [Java]()|Medium|| -|211|Add and Search Word - Data structure design|[Python](python/211 Add and Search Word - Data structure design.py) [Java]()|Medium|| -|225|Implement Stack using Queues|[Python](python/225 Implement Stack using Queues.py) [Java]()|Easy|| -|232|Implement Queue using Stacks|[Python](python/232 Implement Queue using Stacks.py) [Java]()|Easy|| -|244|Shortest Word Distance II|[Python](python/244 Shortest Word Distance II.py) [Java]()|Medium|| -|251|Flatten 2D Vector|[Python](python/251 Flatten 2D Vector.py) [Java]()|Medium|| -|281|Zigzag Iterator|[Python](python/281 Zigzag Iterator.py) [Java]()|Medium|| -|284|Peeking Iterator|[Python](python/284 Peeking Iterator.py) [Java]()|Medium|| -|288|Unique Word Abbreviation|[Python](python/288 Unique Word Abbreviation.py) [Java]()|Medium|| -|295|Find Median from Data Stream|[Python](python/295 Find Median from Data Stream.py) [Java]()|Hard|| -|297|Serialize and Deserialize Binary Tree|[Python](python/297 Serialize and Deserialize Binary Tree.py) [Java]()|Hard|| -|341|Flatten Nested List Iterator|[Python](python/341 Flatten Nested List Iterator.py) [Java]()|Medium|| -|346|Moving Average from Data Stream|[Python](python/346 Moving Average from Data Stream.py) [Java]()|Easy|| -|348|Design Tic-Tac-Toe|[Python](python/348 Design Tic-Tac-Toe.py) [Java]()|Medium|| -|353|Design Snake Game|[Python](python/353 Design Snake Game.py) [Java]()|Medium|| -|355|Design Twitter|[Python](python/355 Design Twitter.py) [Java]()|Medium|| -|359|Logger Rate Limiter|[Python](python/359 Logger Rate Limiter.py) [Java]()|Easy|| -|362|Design Hit Counter|[Python](python/362 Design Hit Counter.py) [Java]()|Medium|| -|379|Design Phone Directory|[Python](python/379 Design Phone Directory.py) [Java]()|Medium|| -|380|Insert Delete GetRandom O(1)|[Python](python/380 Insert Delete GetRandom O(1).py) [Java]()|Medium|| -|381|Insert Delete GetRandom O(1) - Duplicates allowed|[Python](python/381 Insert Delete GetRandom O(1) - Duplicates allowed.py) [Java]()|Hard|| -|432|All O`one Data Structure|[Python](python/432 All O`one Data Structure.py) [Java]()|Hard|| -|460|LFU Cache|[Python](python/460 LFU Cache.py) [Java]()|Hard|| +|146|[LRU Cache](https://leetcode.com/problems/lru-cache)|[Python](./python/146 LRU Cache.py) [Java]()|Hard|| +|155|[Min Stack](https://leetcode.com/problems/min-stack)|[Python](./python/155 Min Stack.py) [Java]()|Easy|| +|170|[Two Sum III - Data structure design](https://leetcode.com/problems/two-sum-iii---data-structure-design)|[Python](./python/170 Two Sum III - Data structure design.py) [Java]()|Easy|| +|173|[Binary Search Tree Iterator](https://leetcode.com/problems/binary-search-tree-iterator)|[Python](./python/173 Binary Search Tree Iterator.py) [Java]()|Medium|| +|208|[Implement Trie (Prefix Tree)](https://leetcode.com/problems/implement-trie-(prefix-tree))|[Python](./python/208 Implement Trie (Prefix Tree).py) [Java]()|Medium|| +|211|[Add and Search Word - Data structure design](https://leetcode.com/problems/add-and-search-word---data-structure-design)|[Python](./python/211 Add and Search Word - Data structure design.py) [Java]()|Medium|| +|225|[Implement Stack using Queues](https://leetcode.com/problems/implement-stack-using-queues)|[Python](./python/225 Implement Stack using Queues.py) [Java]()|Easy|| +|232|[Implement Queue using Stacks](https://leetcode.com/problems/implement-queue-using-stacks)|[Python](./python/232 Implement Queue using Stacks.py) [Java]()|Easy|| +|244|[Shortest Word Distance II](https://leetcode.com/problems/shortest-word-distance-ii)|[Python](./python/244 Shortest Word Distance II.py) [Java]()|Medium|| +|251|[Flatten 2D Vector](https://leetcode.com/problems/flatten-2d-vector)|[Python](./python/251 Flatten 2D Vector.py) [Java]()|Medium|| +|281|[Zigzag Iterator](https://leetcode.com/problems/zigzag-iterator)|[Python](./python/281 Zigzag Iterator.py) [Java]()|Medium|| +|284|[Peeking Iterator](https://leetcode.com/problems/peeking-iterator)|[Python](./python/284 Peeking Iterator.py) [Java]()|Medium|| +|288|[Unique Word Abbreviation](https://leetcode.com/problems/unique-word-abbreviation)|[Python](./python/288 Unique Word Abbreviation.py) [Java]()|Medium|| +|295|[Find Median from Data Stream](https://leetcode.com/problems/find-median-from-data-stream)|[Python](./python/295 Find Median from Data Stream.py) [Java]()|Hard|| +|297|[Serialize and Deserialize Binary Tree](https://leetcode.com/problems/serialize-and-deserialize-binary-tree)|[Python](./python/297 Serialize and Deserialize Binary Tree.py) [Java]()|Hard|| +|341|[Flatten Nested List Iterator](https://leetcode.com/problems/flatten-nested-list-iterator)|[Python](./python/341 Flatten Nested List Iterator.py) [Java]()|Medium|| +|346|[Moving Average from Data Stream](https://leetcode.com/problems/moving-average-from-data-stream)|[Python](./python/346 Moving Average from Data Stream.py) [Java]()|Easy|| +|348|[Design Tic-Tac-Toe](https://leetcode.com/problems/design-tic-tac-toe)|[Python](./python/348 Design Tic-Tac-Toe.py) [Java]()|Medium|| +|353|[Design Snake Game](https://leetcode.com/problems/design-snake-game)|[Python](./python/353 Design Snake Game.py) [Java]()|Medium|| +|355|[Design Twitter](https://leetcode.com/problems/design-twitter)|[Python](./python/355 Design Twitter.py) [Java]()|Medium|| +|359|[Logger Rate Limiter](https://leetcode.com/problems/logger-rate-limiter)|[Python](./python/359 Logger Rate Limiter.py) [Java]()|Easy|| +|362|[Design Hit Counter](https://leetcode.com/problems/design-hit-counter)|[Python](./python/362 Design Hit Counter.py) [Java]()|Medium|| +|379|[Design Phone Directory](https://leetcode.com/problems/design-phone-directory)|[Python](./python/379 Design Phone Directory.py) [Java]()|Medium|| +|380|[Insert Delete GetRandom O(1)](https://leetcode.com/problems/insert-delete-getrandom-o(1))|[Python](./python/380 Insert Delete GetRandom O(1).py) [Java]()|Medium|| +|381|[Insert Delete GetRandom O(1) - Duplicates allowed](https://leetcode.com/problems/insert-delete-getrandom-o(1)---duplicates-allowed)|[Python](./python/381 Insert Delete GetRandom O(1) - Duplicates allowed.py) [Java]()|Hard|| +|432|[All O`one Data Structure](https://leetcode.com/problems/all-o`one-data-structure)|[Python](./python/432 All O`one Data Structure.py) [Java]()|Hard|| +|460|[LFU Cache](https://leetcode.com/problems/lfu-cache)|[Python](./python/460 LFU Cache.py) [Java]()|Hard|| ## Topological Sort | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|207|Course Schedule|[Python](python/207 Course Schedule.py) [Java]()|Medium|| -|210|Course Schedule II|[Python](python/210 Course Schedule II.py) [Java]()|Medium|| -|269|Alien Dictionary|[Python](python/269 Alien Dictionary.py) [Java]()|Hard|| -|329|Longest Increasing Path in a Matrix|[Python](python/329 Longest Increasing Path in a Matrix.py) [Java]()|Hard|| -|444|Sequence Reconstruction|[Python](python/444 Sequence Reconstruction.py) [Java]()|Medium|| +|207|[Course Schedule](https://leetcode.com/problems/course-schedule)|[Python](./python/207 Course Schedule.py) [Java]()|Medium|| +|210|[Course Schedule II](https://leetcode.com/problems/course-schedule-ii)|[Python](./python/210 Course Schedule II.py) [Java]()|Medium|| +|269|[Alien Dictionary](https://leetcode.com/problems/alien-dictionary)|[Python](./python/269 Alien Dictionary.py) [Java]()|Hard|| +|329|[Longest Increasing Path in a Matrix](https://leetcode.com/problems/longest-increasing-path-in-a-matrix)|[Python](./python/329 Longest Increasing Path in a Matrix.py) [Java]()|Hard|| +|444|[Sequence Reconstruction](https://leetcode.com/problems/sequence-reconstruction)|[Python](./python/444 Sequence Reconstruction.py) [Java]()|Medium|| ## Trie | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|208|Implement Trie (Prefix Tree)|[Python](python/208 Implement Trie (Prefix Tree).py) [Java]()|Medium|| -|211|Add and Search Word - Data structure design|[Python](python/211 Add and Search Word - Data structure design.py) [Java]()|Medium|| -|212|Word Search II|[Python](python/212 Word Search II.py) [Java]()|Hard|| -|336|Palindrome Pairs|[Python](python/336 Palindrome Pairs.py) [Java]()|Hard|| -|421|Maximum XOR of Two Numbers in an Array|[Python](python/421 Maximum XOR of Two Numbers in an Array.py) [Java]()|Medium|| -|425|Word Squares|[Python](python/425 Word Squares.py) [Java]()|Hard|| -|472|Concatenated Words|[Python](python/472 Concatenated Words.py) [Java]()|Hard|| +|208|[Implement Trie (Prefix Tree)](https://leetcode.com/problems/implement-trie-(prefix-tree))|[Python](./python/208 Implement Trie (Prefix Tree).py) [Java]()|Medium|| +|211|[Add and Search Word - Data structure design](https://leetcode.com/problems/add-and-search-word---data-structure-design)|[Python](./python/211 Add and Search Word - Data structure design.py) [Java]()|Medium|| +|212|[Word Search II](https://leetcode.com/problems/word-search-ii)|[Python](./python/212 Word Search II.py) [Java]()|Hard|| +|336|[Palindrome Pairs](https://leetcode.com/problems/palindrome-pairs)|[Python](./python/336 Palindrome Pairs.py) [Java]()|Hard|| +|421|[Maximum XOR of Two Numbers in an Array](https://leetcode.com/problems/maximum-xor-of-two-numbers-in-an-array)|[Python](./python/421 Maximum XOR of Two Numbers in an Array.py) [Java]()|Medium|| +|425|[Word Squares](https://leetcode.com/problems/word-squares)|[Python](./python/425 Word Squares.py) [Java]()|Hard|| +|472|[Concatenated Words](https://leetcode.com/problems/concatenated-words)|[Python](./python/472 Concatenated Words.py) [Java]()|Hard|| ## Binary Indexed Tree | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|218|The Skyline Problem|[Python](python/218 The Skyline Problem.py) [Java]()|Hard|| -|307|Range Sum Query - Mutable|[Python](python/307 Range Sum Query - Mutable.py) [Java]()|Medium|| -|308|Range Sum Query 2D - Mutable|[Python](python/308 Range Sum Query 2D - Mutable.py) [Java]()|Hard|| -|315|Count of Smaller Numbers After Self|[Python](python/315 Count of Smaller Numbers After Self.py) [Java]()|Hard|| -|493|Reverse Pairs|[Python](python/493 Reverse Pairs.py) [Java]()|Hard|| +|218|[The Skyline Problem](https://leetcode.com/problems/the-skyline-problem)|[Python](./python/218 The Skyline Problem.py) [Java]()|Hard|| +|307|[Range Sum Query - Mutable](https://leetcode.com/problems/range-sum-query---mutable)|[Python](./python/307 Range Sum Query - Mutable.py) [Java]()|Medium|| +|308|[Range Sum Query 2D - Mutable](https://leetcode.com/problems/range-sum-query-2d---mutable)|[Python](./python/308 Range Sum Query 2D - Mutable.py) [Java]()|Hard|| +|315|[Count of Smaller Numbers After Self](https://leetcode.com/problems/count-of-smaller-numbers-after-self)|[Python](./python/315 Count of Smaller Numbers After Self.py) [Java]()|Hard|| +|493|[Reverse Pairs](https://leetcode.com/problems/reverse-pairs)|[Python](./python/493 Reverse Pairs.py) [Java]()|Hard|| ## Segment Tree | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|218|The Skyline Problem|[Python](python/218 The Skyline Problem.py) [Java]()|Hard|| -|307|Range Sum Query - Mutable|[Python](python/307 Range Sum Query - Mutable.py) [Java]()|Medium|| -|308|Range Sum Query 2D - Mutable|[Python](python/308 Range Sum Query 2D - Mutable.py) [Java]()|Hard|| -|315|Count of Smaller Numbers After Self|[Python](python/315 Count of Smaller Numbers After Self.py) [Java]()|Hard|| -|493|Reverse Pairs|[Python](python/493 Reverse Pairs.py) [Java]()|Hard|| +|218|[The Skyline Problem](https://leetcode.com/problems/the-skyline-problem)|[Python](./python/218 The Skyline Problem.py) [Java]()|Hard|| +|307|[Range Sum Query - Mutable](https://leetcode.com/problems/range-sum-query---mutable)|[Python](./python/307 Range Sum Query - Mutable.py) [Java]()|Medium|| +|308|[Range Sum Query 2D - Mutable](https://leetcode.com/problems/range-sum-query-2d---mutable)|[Python](./python/308 Range Sum Query 2D - Mutable.py) [Java]()|Hard|| +|315|[Count of Smaller Numbers After Self](https://leetcode.com/problems/count-of-smaller-numbers-after-self)|[Python](./python/315 Count of Smaller Numbers After Self.py) [Java]()|Hard|| +|493|[Reverse Pairs](https://leetcode.com/problems/reverse-pairs)|[Python](./python/493 Reverse Pairs.py) [Java]()|Hard|| ## Binary Search Tree | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|220|Contains Duplicate III|[Python](python/220 Contains Duplicate III.py) [Java]()|Medium|| -|315|Count of Smaller Numbers After Self|[Python](python/315 Count of Smaller Numbers After Self.py) [Java]()|Hard|| -|327|Count of Range Sum|[Python](python/327 Count of Range Sum.py) [Java]()|Hard|| -|352|Data Stream as Disjoint Intervals|[Python](python/352 Data Stream as Disjoint Intervals.py) [Java]()|Hard|| -|493|Reverse Pairs|[Python](python/493 Reverse Pairs.py) [Java]()|Hard|| -|530|Minimum Absolute Difference in BST|[Python](python/530 Minimum Absolute Difference in BST.py) [Java]()|Easy|| +|220|[Contains Duplicate III](https://leetcode.com/problems/contains-duplicate-iii)|[Python](./python/220 Contains Duplicate III.py) [Java]()|Medium|| +|315|[Count of Smaller Numbers After Self](https://leetcode.com/problems/count-of-smaller-numbers-after-self)|[Python](./python/315 Count of Smaller Numbers After Self.py) [Java]()|Hard|| +|327|[Count of Range Sum](https://leetcode.com/problems/count-of-range-sum)|[Python](./python/327 Count of Range Sum.py) [Java]()|Hard|| +|352|[Data Stream as Disjoint Intervals](https://leetcode.com/problems/data-stream-as-disjoint-intervals)|[Python](./python/352 Data Stream as Disjoint Intervals.py) [Java]()|Hard|| +|493|[Reverse Pairs](https://leetcode.com/problems/reverse-pairs)|[Python](./python/493 Reverse Pairs.py) [Java]()|Hard|| +|530|[Minimum Absolute Difference in BST](https://leetcode.com/problems/minimum-absolute-difference-in-bst)|[Python](./python/530 Minimum Absolute Difference in BST.py) [Java]()|Easy|| ## Recursion | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|247|Strobogrammatic Number II|[Python](python/247 Strobogrammatic Number II.py) [Java]()|Medium|| -|248|Strobogrammatic Number III|[Python](python/248 Strobogrammatic Number III.py) [Java]()|Hard|| -|544|Output Contest Matches|[Python](python/544 Output Contest Matches.py) [Java]()|Medium|| +|247|[Strobogrammatic Number II](https://leetcode.com/problems/strobogrammatic-number-ii)|[Python](./python/247 Strobogrammatic Number II.py) [Java]()|Medium|| +|248|[Strobogrammatic Number III](https://leetcode.com/problems/strobogrammatic-number-iii)|[Python](./python/248 Strobogrammatic Number III.py) [Java]()|Hard|| +|544|[Output Contest Matches](https://leetcode.com/problems/output-contest-matches)|[Python](./python/544 Output Contest Matches.py) [Java]()|Medium|| ## Brainteaser | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|292|Nim Game|[Python](python/292 Nim Game.py) [Java]()|Easy|| -|319|Bulb Switcher|[Python](python/319 Bulb Switcher.py) [Java]()|Medium|| +|292|[Nim Game](https://leetcode.com/problems/nim-game)|[Python](./python/292 Nim Game.py) [Java]()|Easy|| +|319|[Bulb Switcher](https://leetcode.com/problems/bulb-switcher)|[Python](./python/319 Bulb Switcher.py) [Java]()|Medium|| ## Memoization | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|329|Longest Increasing Path in a Matrix|[Python](python/329 Longest Increasing Path in a Matrix.py) [Java]()|Hard|| +|329|[Longest Increasing Path in a Matrix](https://leetcode.com/problems/longest-increasing-path-in-a-matrix)|[Python](./python/329 Longest Increasing Path in a Matrix.py) [Java]()|Hard|| ## Queue | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|346|Moving Average from Data Stream|[Python](python/346 Moving Average from Data Stream.py) [Java]()|Easy|| -|353|Design Snake Game|[Python](python/353 Design Snake Game.py) [Java]()|Medium|| -|363|Max Sum of Rectangle No Larger Than K|[Python](python/363 Max Sum of Rectangle No Larger Than K.py) [Java]()|Hard|| +|346|[Moving Average from Data Stream](https://leetcode.com/problems/moving-average-from-data-stream)|[Python](./python/346 Moving Average from Data Stream.py) [Java]()|Easy|| +|353|[Design Snake Game](https://leetcode.com/problems/design-snake-game)|[Python](./python/353 Design Snake Game.py) [Java]()|Medium|| +|363|[Max Sum of Rectangle No Larger Than K](https://leetcode.com/problems/max-sum-of-rectangle-no-larger-than-k)|[Python](./python/363 Max Sum of Rectangle No Larger Than K.py) [Java]()|Hard|| ## Minimax | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|375|Guess Number Higher or Lower II|[Python](python/375 Guess Number Higher or Lower II.py) [Java]()|Medium|| -|464|Can I Win|[Python](python/464 Can I Win.py) [Java]()|Medium|| -|486|Predict the Winner|[Python](python/486 Predict the Winner.py) [Java]()|Medium|| +|375|[Guess Number Higher or Lower II](https://leetcode.com/problems/guess-number-higher-or-lower-ii)|[Python](./python/375 Guess Number Higher or Lower II.py) [Java]()|Medium|| +|464|[Can I Win](https://leetcode.com/problems/can-i-win)|[Python](./python/464 Can I Win.py) [Java]()|Medium|| +|486|[Predict the Winner](https://leetcode.com/problems/predict-the-winner)|[Python](./python/486 Predict the Winner.py) [Java]()|Medium|| ## Reservoir Sampling | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|382|Linked List Random Node|[Python](python/382 Linked List Random Node.py) [Java]()|Medium|| -|398|Random Pick Index|[Python](python/398 Random Pick Index.py) [Java]()|Medium|| \ No newline at end of file +|382|[Linked List Random Node](https://leetcode.com/problems/linked-list-random-node)|[Python](./python/382 Linked List Random Node.py) [Java]()|Medium|| +|398|[Random Pick Index](https://leetcode.com/problems/random-pick-index)|[Python](./python/398 Random Pick Index.py) [Java]()|Medium|| \ No newline at end of file From 920304cd53aac6983f22d6fcab45df97733c71c7 Mon Sep 17 00:00:00 2001 From: Shen Jie Date: Tue, 2 May 2017 16:39:52 +0800 Subject: [PATCH 13/53] Fix link errors in tags --- TAG.md | 1600 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 800 insertions(+), 800 deletions(-) diff --git a/TAG.md b/TAG.md index 6a606cd..51478b3 100644 --- a/TAG.md +++ b/TAG.md @@ -1,947 +1,947 @@ # Tag -- [Array](https://github.com/gavinfish/leetcode-share#array) -- [Hash Table](https://github.com/gavinfish/leetcode-share#hash-table) -- [Linked List](https://github.com/gavinfish/leetcode-share#linked-list) -- [Math](https://github.com/gavinfish/leetcode-share#math) -- [Two Pointers](https://github.com/gavinfish/leetcode-share#two-pointers) -- [String](https://github.com/gavinfish/leetcode-share#string) -- [Binary Search](https://github.com/gavinfish/leetcode-share#binary-search) -- [Divide and Conquer](https://github.com/gavinfish/leetcode-share#divide-and-conquer) -- [Dynamic Programming](https://github.com/gavinfish/leetcode-share#dynamic-programming) -- [Backtracking](https://github.com/gavinfish/leetcode-share#backtracking) -- [Stack](https://github.com/gavinfish/leetcode-share#stack) -- [Heap](https://github.com/gavinfish/leetcode-share#heap) -- [Tree](https://github.com/gavinfish/leetcode-share#tree) -- [Depth-first Search](https://github.com/gavinfish/leetcode-share#depth-first-search) -- [Breadth-first Search](https://github.com/gavinfish/leetcode-share#breadth-first-search) -- [Union Find](https://github.com/gavinfish/leetcode-share#union-find) -- [Graph](https://github.com/gavinfish/leetcode-share#graph) -- [Design](https://github.com/gavinfish/leetcode-share#design) -- [Topological Sort](https://github.com/gavinfish/leetcode-share#topological-sort) -- [Trie](https://github.com/gavinfish/leetcode-share#trie) -- [Binary Indexed Tree](https://github.com/gavinfish/leetcode-share#binary-indexed-tree) -- [Segment Tree](https://github.com/gavinfish/leetcode-share#segment-tree) -- [Binary Search Tree](https://github.com/gavinfish/leetcode-share#binary-search-tree) -- [Recursion](https://github.com/gavinfish/leetcode-share#recursion) -- [Brainteaser](https://github.com/gavinfish/leetcode-share#brainteaser) -- [Memoization](https://github.com/gavinfish/leetcode-share#memoization) -- [Queue](https://github.com/gavinfish/leetcode-share#queue) -- [Minimax](https://github.com/gavinfish/leetcode-share#minimax) -- [Reservoir Sampling](https://github.com/gavinfish/leetcode-share#reservoir-sampling) +- [Array](https://github.com/gavinfish/leetcode-share/blob/master/TAG.md#array) +- [Hash Table](https://github.com/gavinfish/leetcode-share/blob/master/TAG.md#hash-table) +- [Linked List](https://github.com/gavinfish/leetcode-share/blob/master/TAG.md#linked-list) +- [Math](https://github.com/gavinfish/leetcode-share/blob/master/TAG.md#math) +- [Two Pointers](https://github.com/gavinfish/leetcode-share/blob/master/TAG.md#two-pointers) +- [String](https://github.com/gavinfish/leetcode-share/blob/master/TAG.md#string) +- [Binary Search](https://github.com/gavinfish/leetcode-share/blob/master/TAG.md#binary-search) +- [Divide and Conquer](https://github.com/gavinfish/leetcode-share/blob/master/TAG.md#divide-and-conquer) +- [Dynamic Programming](https://github.com/gavinfish/leetcode-share/blob/master/TAG.md#dynamic-programming) +- [Backtracking](https://github.com/gavinfish/leetcode-share/blob/master/TAG.md#backtracking) +- [Stack](https://github.com/gavinfish/leetcode-share/blob/master/TAG.md#stack) +- [Heap](https://github.com/gavinfish/leetcode-share/blob/master/TAG.md#heap) +- [Tree](https://github.com/gavinfish/leetcode-share/blob/master/TAG.md#tree) +- [Depth-first Search](https://github.com/gavinfish/leetcode-share/blob/master/TAG.md#depth-first-search) +- [Breadth-first Search](https://github.com/gavinfish/leetcode-share/blob/master/TAG.md#breadth-first-search) +- [Union Find](https://github.com/gavinfish/leetcode-share/blob/master/TAG.md#union-find) +- [Graph](https://github.com/gavinfish/leetcode-share/blob/master/TAG.md#graph) +- [Design](https://github.com/gavinfish/leetcode-share/blob/master/TAG.md#design) +- [Topological Sort](https://github.com/gavinfish/leetcode-share/blob/master/TAG.md#topological-sort) +- [Trie](https://github.com/gavinfish/leetcode-share/blob/master/TAG.md#trie) +- [Binary Indexed Tree](https://github.com/gavinfish/leetcode-share/blob/master/TAG.md#binary-indexed-tree) +- [Segment Tree](https://github.com/gavinfish/leetcode-share/blob/master/TAG.md#segment-tree) +- [Binary Search Tree](https://github.com/gavinfish/leetcode-share/blob/master/TAG.md#binary-search-tree) +- [Recursion](https://github.com/gavinfish/leetcode-share/blob/master/TAG.md#recursion) +- [Brainteaser](https://github.com/gavinfish/leetcode-share/blob/master/TAG.md#brainteaser) +- [Memoization](https://github.com/gavinfish/leetcode-share/blob/master/TAG.md#memoization) +- [Queue](https://github.com/gavinfish/leetcode-share/blob/master/TAG.md#queue) +- [Minimax](https://github.com/gavinfish/leetcode-share/blob/master/TAG.md#minimax) +- [Reservoir Sampling](https://github.com/gavinfish/leetcode-share/blob/master/TAG.md#reservoir-sampling) ## Array | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|1|[Two Sum](https://leetcode.com/problems/two-sum)|[Python](./python/001 Two Sum.py) [Java]()|Easy|| -|4|[Median of Two Sorted Arrays](https://leetcode.com/problems/median-of-two-sorted-arrays)|[Python](./python/004 Median of Two Sorted Arrays.py) [Java]()|Hard|| -|11|[Container With Most Water](https://leetcode.com/problems/container-with-most-water)|[Python](./python/011 Container With Most Water.py) [Java]()|Medium|| -|15|[3Sum](https://leetcode.com/problems/3sum)|[Python](./python/015 3Sum.py) [Java]()|Medium|| -|16|[3Sum Closest](https://leetcode.com/problems/3sum-closest)|[Python](./python/016 3Sum Closest.py) [Java]()|Medium|| -|18|[4Sum](https://leetcode.com/problems/4sum)|[Python](./python/018 4Sum.py) [Java]()|Medium|| -|26|[Remove Duplicates from Sorted Array](https://leetcode.com/problems/remove-duplicates-from-sorted-array)|[Python](./python/026 Remove Duplicates from Sorted Array.py) [Java]()|Easy|| -|27|[Remove Element](https://leetcode.com/problems/remove-element)|[Python](./python/027 Remove Element.py) [Java]()|Easy|| -|31|[Next Permutation](https://leetcode.com/problems/next-permutation)|[Python](./python/031 Next Permutation.py) [Java]()|Medium|| -|33|[Search in Rotated Sorted Array](https://leetcode.com/problems/search-in-rotated-sorted-array)|[Python](./python/033 Search in Rotated Sorted Array.py) [Java]()|Medium|| -|34|[Search for a Range](https://leetcode.com/problems/search-for-a-range)|[Python](./python/034 Search for a Range.py) [Java]()|Medium|| -|35|[Search Insert Position](https://leetcode.com/problems/search-insert-position)|[Python](./python/035 Search Insert Position.py) [Java]()|Easy|| -|39|[Combination Sum](https://leetcode.com/problems/combination-sum)|[Python](./python/039 Combination Sum.py) [Java]()|Medium|| -|40|[Combination Sum II](https://leetcode.com/problems/combination-sum-ii)|[Python](./python/040 Combination Sum II.py) [Java]()|Medium|| -|41|[First Missing Positive](https://leetcode.com/problems/first-missing-positive)|[Python](./python/041 First Missing Positive.py) [Java]()|Hard|| -|42|[Trapping Rain Water](https://leetcode.com/problems/trapping-rain-water)|[Python](./python/042 Trapping Rain Water.py) [Java]()|Hard|| -|45|[Jump Game II](https://leetcode.com/problems/jump-game-ii)|[Python](./python/045 Jump Game II.py) [Java]()|Hard|| -|48|[Rotate Image](https://leetcode.com/problems/rotate-image)|[Python](./python/048 Rotate Image.py) [Java]()|Medium|| -|53|[Maximum Subarray](https://leetcode.com/problems/maximum-subarray)|[Python](./python/053 Maximum Subarray.py) [Java]()|Easy|| -|54|[Spiral Matrix](https://leetcode.com/problems/spiral-matrix)|[Python](./python/054 Spiral Matrix.py) [Java]()|Medium|| -|55|[Jump Game](https://leetcode.com/problems/jump-game)|[Python](./python/055 Jump Game.py) [Java]()|Medium|| -|56|[Merge Intervals](https://leetcode.com/problems/merge-intervals)|[Python](./python/056 Merge Intervals.py) [Java]()|Medium|| -|57|[Insert Interval](https://leetcode.com/problems/insert-interval)|[Python](./python/057 Insert Interval.py) [Java]()|Hard|| -|59|[Spiral Matrix II](https://leetcode.com/problems/spiral-matrix-ii)|[Python](./python/059 Spiral Matrix II.py) [Java]()|Medium|| -|62|[Unique Paths](https://leetcode.com/problems/unique-paths)|[Python](./python/062 Unique Paths.py) [Java]()|Medium|| -|63|[Unique Paths II](https://leetcode.com/problems/unique-paths-ii)|[Python](./python/063 Unique Paths II.py) [Java]()|Medium|| -|64|[Minimum Path Sum](https://leetcode.com/problems/minimum-path-sum)|[Python](./python/064 Minimum Path Sum.py) [Java]()|Medium|| -|66|[Plus One](https://leetcode.com/problems/plus-one)|[Python](./python/066 Plus One.py) [Java]()|Easy|| -|73|[Set Matrix Zeroes](https://leetcode.com/problems/set-matrix-zeroes)|[Python](./python/073 Set Matrix Zeroes.py) [Java]()|Medium|| -|74|[Search a 2D Matrix](https://leetcode.com/problems/search-a-2d-matrix)|[Python](./python/074 Search a 2D Matrix.py) [Java]()|Medium|| -|75|[Sort Colors](https://leetcode.com/problems/sort-colors)|[Python](./python/075 Sort Colors.py) [Java]()|Medium|| -|78|[Subsets](https://leetcode.com/problems/subsets)|[Python](./python/078 Subsets.py) [Java]()|Medium|| -|79|[Word Search](https://leetcode.com/problems/word-search)|[Python](./python/079 Word Search.py) [Java]()|Medium|| -|80|[Remove Duplicates from Sorted Array II](https://leetcode.com/problems/remove-duplicates-from-sorted-array-ii)|[Python](./python/080 Remove Duplicates from Sorted Array II.py) [Java]()|Medium|| -|81|[Search in Rotated Sorted Array II](https://leetcode.com/problems/search-in-rotated-sorted-array-ii)|[Python](./python/081 Search in Rotated Sorted Array II.py) [Java]()|Medium|| -|84|[Largest Rectangle in Histogram](https://leetcode.com/problems/largest-rectangle-in-histogram)|[Python](./python/084 Largest Rectangle in Histogram.py) [Java]()|Hard|| -|85|[Maximal Rectangle](https://leetcode.com/problems/maximal-rectangle)|[Python](./python/085 Maximal Rectangle.py) [Java]()|Hard|| -|88|[Merge Sorted Array](https://leetcode.com/problems/merge-sorted-array)|[Python](./python/088 Merge Sorted Array.py) [Java]()|Easy|| -|90|[Subsets II](https://leetcode.com/problems/subsets-ii)|[Python](./python/090 Subsets II.py) [Java]()|Medium|| -|105|[Construct Binary Tree from Preorder and Inorder Traversal](https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal)|[Python](./python/105 Construct Binary Tree from Preorder and Inorder Traversal.py) [Java]()|Medium|| -|106|[Construct Binary Tree from Inorder and Postorder Traversal](https://leetcode.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal)|[Python](./python/106 Construct Binary Tree from Inorder and Postorder Traversal.py) [Java]()|Medium|| -|118|[Pascal's Triangle](https://leetcode.com/problems/pascal's-triangle)|[Python](./python/118 Pascal's Triangle.py) [Java]()|Easy|| -|119|[Pascal's Triangle II](https://leetcode.com/problems/pascal's-triangle-ii)|[Python](./python/119 Pascal's Triangle II.py) [Java]()|Easy|| -|120|[Triangle](https://leetcode.com/problems/triangle)|[Python](./python/120 Triangle.py) [Java]()|Medium|| -|121|[Best Time to Buy and Sell Stock](https://leetcode.com/problems/best-time-to-buy-and-sell-stock)|[Python](./python/121 Best Time to Buy and Sell Stock.py) [Java]()|Easy|| -|122|[Best Time to Buy and Sell Stock II](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii)|[Python](./python/122 Best Time to Buy and Sell Stock II.py) [Java]()|Easy|| -|123|[Best Time to Buy and Sell Stock III](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iii)|[Python](./python/123 Best Time to Buy and Sell Stock III.py) [Java]()|Hard|| -|126|[Word Ladder II](https://leetcode.com/problems/word-ladder-ii)|[Python](./python/126 Word Ladder II.py) [Java]()|Hard|| -|128|[Longest Consecutive Sequence](https://leetcode.com/problems/longest-consecutive-sequence)|[Python](./python/128 Longest Consecutive Sequence.py) [Java]()|Hard|| -|152|[Maximum Product Subarray](https://leetcode.com/problems/maximum-product-subarray)|[Python](./python/152 Maximum Product Subarray.py) [Java]()|Medium|| -|153|[Find Minimum in Rotated Sorted Array](https://leetcode.com/problems/find-minimum-in-rotated-sorted-array)|[Python](./python/153 Find Minimum in Rotated Sorted Array.py) [Java]()|Medium|| -|154|[Find Minimum in Rotated Sorted Array II](https://leetcode.com/problems/find-minimum-in-rotated-sorted-array-ii)|[Python](./python/154 Find Minimum in Rotated Sorted Array II.py) [Java]()|Hard|| -|162|[Find Peak Element](https://leetcode.com/problems/find-peak-element)|[Python](./python/162 Find Peak Element.py) [Java]()|Medium|| -|163|[Missing Ranges](https://leetcode.com/problems/missing-ranges)|[Python](./python/163 Missing Ranges.py) [Java]()|Medium|| -|167|[Two Sum II - Input array is sorted](https://leetcode.com/problems/two-sum-ii---input-array-is-sorted)|[Python](./python/167 Two Sum II - Input array is sorted.py) [Java]()|Easy|| -|169|[Majority Element](https://leetcode.com/problems/majority-element)|[Python](./python/169 Majority Element.py) [Java]()|Easy|| -|189|[Rotate Array](https://leetcode.com/problems/rotate-array)|[Python](./python/189 Rotate Array.py) [Java]()|Easy|| -|209|[Minimum Size Subarray Sum](https://leetcode.com/problems/minimum-size-subarray-sum)|[Python](./python/209 Minimum Size Subarray Sum.py) [Java]()|Medium|| -|216|[Combination Sum III](https://leetcode.com/problems/combination-sum-iii)|[Python](./python/216 Combination Sum III.py) [Java]()|Medium|| -|217|[Contains Duplicate](https://leetcode.com/problems/contains-duplicate)|[Python](./python/217 Contains Duplicate.py) [Java]()|Easy|| -|219|[Contains Duplicate II](https://leetcode.com/problems/contains-duplicate-ii)|[Python](./python/219 Contains Duplicate II.py) [Java]()|Easy|| -|228|[Summary Ranges](https://leetcode.com/problems/summary-ranges)|[Python](./python/228 Summary Ranges.py) [Java]()|Medium|| -|229|[Majority Element II](https://leetcode.com/problems/majority-element-ii)|[Python](./python/229 Majority Element II.py) [Java]()|Medium|| -|238|[Product of Array Except Self](https://leetcode.com/problems/product-of-array-except-self)|[Python](./python/238 Product of Array Except Self.py) [Java]()|Medium|| -|243|[Shortest Word Distance](https://leetcode.com/problems/shortest-word-distance)|[Python](./python/243 Shortest Word Distance.py) [Java]()|Easy|| -|245|[Shortest Word Distance III](https://leetcode.com/problems/shortest-word-distance-iii)|[Python](./python/245 Shortest Word Distance III.py) [Java]()|Medium|| -|259|[3Sum Smaller](https://leetcode.com/problems/3sum-smaller)|[Python](./python/259 3Sum Smaller.py) [Java]()|Medium|| -|268|[Missing Number](https://leetcode.com/problems/missing-number)|[Python](./python/268 Missing Number.py) [Java]()|Easy|| -|277|[Find the Celebrity](https://leetcode.com/problems/find-the-celebrity)|[Python](./python/277 Find the Celebrity.py) [Java]()|Medium|| -|280|[Wiggle Sort](https://leetcode.com/problems/wiggle-sort)|[Python](./python/280 Wiggle Sort.py) [Java]()|Medium|| -|283|[Move Zeroes](https://leetcode.com/problems/move-zeroes)|[Python](./python/283 Move Zeroes.py) [Java]()|Easy|| -|287|[Find the Duplicate Number](https://leetcode.com/problems/find-the-duplicate-number)|[Python](./python/287 Find the Duplicate Number.py) [Java]()|Medium|| -|289|[Game of Life](https://leetcode.com/problems/game-of-life)|[Python](./python/289 Game of Life.py) [Java]()|Medium|| -|370|[Range Addition](https://leetcode.com/problems/range-addition)|[Python](./python/370 Range Addition.py) [Java]()|Medium|| -|380|[Insert Delete GetRandom O(1)](https://leetcode.com/problems/insert-delete-getrandom-o(1))|[Python](./python/380 Insert Delete GetRandom O(1).py) [Java]()|Medium|| -|381|[Insert Delete GetRandom O(1) - Duplicates allowed](https://leetcode.com/problems/insert-delete-getrandom-o(1)---duplicates-allowed)|[Python](./python/381 Insert Delete GetRandom O(1) - Duplicates allowed.py) [Java]()|Hard|| -|414|[Third Maximum Number](https://leetcode.com/problems/third-maximum-number)|[Python](./python/414 Third Maximum Number.py) [Java]()|Easy|| -|442|[Find All Duplicates in an Array](https://leetcode.com/problems/find-all-duplicates-in-an-array)|[Python](./python/442 Find All Duplicates in an Array.py) [Java]()|Medium|| -|448|[Find All Numbers Disappeared in an Array](https://leetcode.com/problems/find-all-numbers-disappeared-in-an-array)|[Python](./python/448 Find All Numbers Disappeared in an Array.py) [Java]()|Easy|| -|485|[Max Consecutive Ones](https://leetcode.com/problems/max-consecutive-ones)|[Python](./python/485 Max Consecutive Ones.py) [Java]()|Easy|| -|495|[Teemo Attacking](https://leetcode.com/problems/teemo-attacking)|[Python](./python/495 Teemo Attacking.py) [Java]()|Medium|| -|531|[Lonely Pixel I](https://leetcode.com/problems/lonely-pixel-i)|[Python](./python/531 Lonely Pixel I.py) [Java]()|Medium|| -|532|[K-diff Pairs in an Array](https://leetcode.com/problems/k-diff-pairs-in-an-array)|[Python](./python/532 K-diff Pairs in an Array.py) [Java]()|Easy|| -|533|[Lonely Pixel II](https://leetcode.com/problems/lonely-pixel-ii)|[Python](./python/533 Lonely Pixel II.py) [Java]()|Medium|| -|548|[Split Array with Equal Sum](https://leetcode.com/problems/split-array-with-equal-sum)|[Python](./python/548 Split Array with Equal Sum.py) [Java]()|Medium|| -|560|[Subarray Sum Equals K](https://leetcode.com/problems/subarray-sum-equals-k)|[Python](./python/560 Subarray Sum Equals K.py) [Java]()|Medium|| -|561|[Array Partition I](https://leetcode.com/problems/array-partition-i)|[Python](./python/561 Array Partition I.py) [Java]()|Easy|| -|562|[Longest Line of Consecutive One in Matrix](https://leetcode.com/problems/longest-line-of-consecutive-one-in-matrix)|[Python](./python/562 Longest Line of Consecutive One in Matrix.py) [Java]()|Medium|| -|566|[Reshape the Matrix](https://leetcode.com/problems/reshape-the-matrix)|[Python](./python/566 Reshape the Matrix.py) [Java]()|Easy|| +|1|[Two Sum](https://leetcode.com/problems/two-sum)| [Python](./python/001%20Two%20Sum.py) [Java]() |Easy|| +|4|[Median of Two Sorted Arrays](https://leetcode.com/problems/median-of-two-sorted-arrays)| [Python](./python/004%20Median%20of%20Two%20Sorted%20Arrays.py) [Java]() |Hard|| +|11|[Container With Most Water](https://leetcode.com/problems/container-with-most-water)| [Python](./python/011%20Container%20With%20Most%20Water.py) [Java]() |Medium|| +|15|[3Sum](https://leetcode.com/problems/3sum)| [Python](./python/015%203Sum.py) [Java]() |Medium|| +|16|[3Sum Closest](https://leetcode.com/problems/3sum-closest)| [Python](./python/016%203Sum%20Closest.py) [Java]() |Medium|| +|18|[4Sum](https://leetcode.com/problems/4sum)| [Python](./python/018%204Sum.py) [Java]() |Medium|| +|26|[Remove Duplicates from Sorted Array](https://leetcode.com/problems/remove-duplicates-from-sorted-array)| [Python](./python/026%20Remove%20Duplicates%20from%20Sorted%20Array.py) [Java]() |Easy|| +|27|[Remove Element](https://leetcode.com/problems/remove-element)| [Python](./python/027%20Remove%20Element.py) [Java]() |Easy|| +|31|[Next Permutation](https://leetcode.com/problems/next-permutation)| [Python](./python/031%20Next%20Permutation.py) [Java]() |Medium|| +|33|[Search in Rotated Sorted Array](https://leetcode.com/problems/search-in-rotated-sorted-array)| [Python](./python/033%20Search%20in%20Rotated%20Sorted%20Array.py) [Java]() |Medium|| +|34|[Search for a Range](https://leetcode.com/problems/search-for-a-range)| [Python](./python/034%20Search%20for%20a%20Range.py) [Java]() |Medium|| +|35|[Search Insert Position](https://leetcode.com/problems/search-insert-position)| [Python](./python/035%20Search%20Insert%20Position.py) [Java]() |Easy|| +|39|[Combination Sum](https://leetcode.com/problems/combination-sum)| [Python](./python/039%20Combination%20Sum.py) [Java]() |Medium|| +|40|[Combination Sum II](https://leetcode.com/problems/combination-sum-ii)| [Python](./python/040%20Combination%20Sum%20II.py) [Java]() |Medium|| +|41|[First Missing Positive](https://leetcode.com/problems/first-missing-positive)| [Python](./python/041%20First%20Missing%20Positive.py) [Java]() |Hard|| +|42|[Trapping Rain Water](https://leetcode.com/problems/trapping-rain-water)| [Python](./python/042%20Trapping%20Rain%20Water.py) [Java]() |Hard|| +|45|[Jump Game II](https://leetcode.com/problems/jump-game-ii)| [Python](./python/045%20Jump%20Game%20II.py) [Java]() |Hard|| +|48|[Rotate Image](https://leetcode.com/problems/rotate-image)| [Python](./python/048%20Rotate%20Image.py) [Java]() |Medium|| +|53|[Maximum Subarray](https://leetcode.com/problems/maximum-subarray)| [Python](./python/053%20Maximum%20Subarray.py) [Java]() |Easy|| +|54|[Spiral Matrix](https://leetcode.com/problems/spiral-matrix)| [Python](./python/054%20Spiral%20Matrix.py) [Java]() |Medium|| +|55|[Jump Game](https://leetcode.com/problems/jump-game)| [Python](./python/055%20Jump%20Game.py) [Java]() |Medium|| +|56|[Merge Intervals](https://leetcode.com/problems/merge-intervals)| [Python](./python/056%20Merge%20Intervals.py) [Java]() |Medium|| +|57|[Insert Interval](https://leetcode.com/problems/insert-interval)| [Python](./python/057%20Insert%20Interval.py) [Java]() |Hard|| +|59|[Spiral Matrix II](https://leetcode.com/problems/spiral-matrix-ii)| [Python](./python/059%20Spiral%20Matrix%20II.py) [Java]() |Medium|| +|62|[Unique Paths](https://leetcode.com/problems/unique-paths)| [Python](./python/062%20Unique%20Paths.py) [Java]() |Medium|| +|63|[Unique Paths II](https://leetcode.com/problems/unique-paths-ii)| [Python](./python/063%20Unique%20Paths%20II.py) [Java]() |Medium|| +|64|[Minimum Path Sum](https://leetcode.com/problems/minimum-path-sum)| [Python](./python/064%20Minimum%20Path%20Sum.py) [Java]() |Medium|| +|66|[Plus One](https://leetcode.com/problems/plus-one)| [Python](./python/066%20Plus%20One.py) [Java]() |Easy|| +|73|[Set Matrix Zeroes](https://leetcode.com/problems/set-matrix-zeroes)| [Python](./python/073%20Set%20Matrix%20Zeroes.py) [Java]() |Medium|| +|74|[Search a 2D Matrix](https://leetcode.com/problems/search-a-2d-matrix)| [Python](./python/074%20Search%20a%202D%20Matrix.py) [Java]() |Medium|| +|75|[Sort Colors](https://leetcode.com/problems/sort-colors)| [Python](./python/075%20Sort%20Colors.py) [Java]() |Medium|| +|78|[Subsets](https://leetcode.com/problems/subsets)| [Python](./python/078%20Subsets.py) [Java]() |Medium|| +|79|[Word Search](https://leetcode.com/problems/word-search)| [Python](./python/079%20Word%20Search.py) [Java]() |Medium|| +|80|[Remove Duplicates from Sorted Array II](https://leetcode.com/problems/remove-duplicates-from-sorted-array-ii)| [Python](./python/080%20Remove%20Duplicates%20from%20Sorted%20Array%20II.py) [Java]() |Medium|| +|81|[Search in Rotated Sorted Array II](https://leetcode.com/problems/search-in-rotated-sorted-array-ii)| [Python](./python/081%20Search%20in%20Rotated%20Sorted%20Array%20II.py) [Java]() |Medium|| +|84|[Largest Rectangle in Histogram](https://leetcode.com/problems/largest-rectangle-in-histogram)| [Python](./python/084%20Largest%20Rectangle%20in%20Histogram.py) [Java]() |Hard|| +|85|[Maximal Rectangle](https://leetcode.com/problems/maximal-rectangle)| [Python](./python/085%20Maximal%20Rectangle.py) [Java]() |Hard|| +|88|[Merge Sorted Array](https://leetcode.com/problems/merge-sorted-array)| [Python](./python/088%20Merge%20Sorted%20Array.py) [Java]() |Easy|| +|90|[Subsets II](https://leetcode.com/problems/subsets-ii)| [Python](./python/090%20Subsets%20II.py) [Java]() |Medium|| +|105|[Construct Binary Tree from Preorder and Inorder Traversal](https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal)| [Python](./python/105%20Construct%20Binary%20Tree%20from%20Preorder%20and%20Inorder%20Traversal.py) [Java]() |Medium|| +|106|[Construct Binary Tree from Inorder and Postorder Traversal](https://leetcode.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal)| [Python](./python/106%20Construct%20Binary%20Tree%20from%20Inorder%20and%20Postorder%20Traversal.py) [Java]() |Medium|| +|118|[Pascal's Triangle](https://leetcode.com/problems/pascal's-triangle)| [Python](./python/118%20Pascal's%20Triangle.py) [Java]() |Easy|| +|119|[Pascal's Triangle II](https://leetcode.com/problems/pascal's-triangle-ii)| [Python](./python/119%20Pascal's%20Triangle%20II.py) [Java]() |Easy|| +|120|[Triangle](https://leetcode.com/problems/triangle)| [Python](./python/120%20Triangle.py) [Java]() |Medium|| +|121|[Best Time to Buy and Sell Stock](https://leetcode.com/problems/best-time-to-buy-and-sell-stock)| [Python](./python/121%20Best%20Time%20to%20Buy%20and%20Sell%20Stock.py) [Java]() |Easy|| +|122|[Best Time to Buy and Sell Stock II](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii)| [Python](./python/122%20Best%20Time%20to%20Buy%20and%20Sell%20Stock%20II.py) [Java]() |Easy|| +|123|[Best Time to Buy and Sell Stock III](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iii)| [Python](./python/123%20Best%20Time%20to%20Buy%20and%20Sell%20Stock%20III.py) [Java]() |Hard|| +|126|[Word Ladder II](https://leetcode.com/problems/word-ladder-ii)| [Python](./python/126%20Word%20Ladder%20II.py) [Java]() |Hard|| +|128|[Longest Consecutive Sequence](https://leetcode.com/problems/longest-consecutive-sequence)| [Python](./python/128%20Longest%20Consecutive%20Sequence.py) [Java]() |Hard|| +|152|[Maximum Product Subarray](https://leetcode.com/problems/maximum-product-subarray)| [Python](./python/152%20Maximum%20Product%20Subarray.py) [Java]() |Medium|| +|153|[Find Minimum in Rotated Sorted Array](https://leetcode.com/problems/find-minimum-in-rotated-sorted-array)| [Python](./python/153%20Find%20Minimum%20in%20Rotated%20Sorted%20Array.py) [Java]() |Medium|| +|154|[Find Minimum in Rotated Sorted Array II](https://leetcode.com/problems/find-minimum-in-rotated-sorted-array-ii)| [Python](./python/154%20Find%20Minimum%20in%20Rotated%20Sorted%20Array%20II.py) [Java]() |Hard|| +|162|[Find Peak Element](https://leetcode.com/problems/find-peak-element)| [Python](./python/162%20Find%20Peak%20Element.py) [Java]() |Medium|| +|163|[Missing Ranges](https://leetcode.com/problems/missing-ranges)| [Python](./python/163%20Missing%20Ranges.py) [Java]() |Medium|| +|167|[Two Sum II - Input array is sorted](https://leetcode.com/problems/two-sum-ii---input-array-is-sorted)| [Python](./python/167%20Two%20Sum%20II%20-%20Input%20array%20is%20sorted.py) [Java]() |Easy|| +|169|[Majority Element](https://leetcode.com/problems/majority-element)| [Python](./python/169%20Majority%20Element.py) [Java]() |Easy|| +|189|[Rotate Array](https://leetcode.com/problems/rotate-array)| [Python](./python/189%20Rotate%20Array.py) [Java]() |Easy|| +|209|[Minimum Size Subarray Sum](https://leetcode.com/problems/minimum-size-subarray-sum)| [Python](./python/209%20Minimum%20Size%20Subarray%20Sum.py) [Java]() |Medium|| +|216|[Combination Sum III](https://leetcode.com/problems/combination-sum-iii)| [Python](./python/216%20Combination%20Sum%20III.py) [Java]() |Medium|| +|217|[Contains Duplicate](https://leetcode.com/problems/contains-duplicate)| [Python](./python/217%20Contains%20Duplicate.py) [Java]() |Easy|| +|219|[Contains Duplicate II](https://leetcode.com/problems/contains-duplicate-ii)| [Python](./python/219%20Contains%20Duplicate%20II.py) [Java]() |Easy|| +|228|[Summary Ranges](https://leetcode.com/problems/summary-ranges)| [Python](./python/228%20Summary%20Ranges.py) [Java]() |Medium|| +|229|[Majority Element II](https://leetcode.com/problems/majority-element-ii)| [Python](./python/229%20Majority%20Element%20II.py) [Java]() |Medium|| +|238|[Product of Array Except Self](https://leetcode.com/problems/product-of-array-except-self)| [Python](./python/238%20Product%20of%20Array%20Except%20Self.py) [Java]() |Medium|| +|243|[Shortest Word Distance](https://leetcode.com/problems/shortest-word-distance)| [Python](./python/243%20Shortest%20Word%20Distance.py) [Java]() |Easy|| +|245|[Shortest Word Distance III](https://leetcode.com/problems/shortest-word-distance-iii)| [Python](./python/245%20Shortest%20Word%20Distance%20III.py) [Java]() |Medium|| +|259|[3Sum Smaller](https://leetcode.com/problems/3sum-smaller)| [Python](./python/259%203Sum%20Smaller.py) [Java]() |Medium|| +|268|[Missing Number](https://leetcode.com/problems/missing-number)| [Python](./python/268%20Missing%20Number.py) [Java]() |Easy|| +|277|[Find the Celebrity](https://leetcode.com/problems/find-the-celebrity)| [Python](./python/277%20Find%20the%20Celebrity.py) [Java]() |Medium|| +|280|[Wiggle Sort](https://leetcode.com/problems/wiggle-sort)| [Python](./python/280%20Wiggle%20Sort.py) [Java]() |Medium|| +|283|[Move Zeroes](https://leetcode.com/problems/move-zeroes)| [Python](./python/283%20Move%20Zeroes.py) [Java]() |Easy|| +|287|[Find the Duplicate Number](https://leetcode.com/problems/find-the-duplicate-number)| [Python](./python/287%20Find%20the%20Duplicate%20Number.py) [Java]() |Medium|| +|289|[Game of Life](https://leetcode.com/problems/game-of-life)| [Python](./python/289%20Game%20of%20Life.py) [Java]() |Medium|| +|370|[Range Addition](https://leetcode.com/problems/range-addition)| [Python](./python/370%20Range%20Addition.py) [Java]() |Medium|| +|380|[Insert Delete GetRandom O(1)](https://leetcode.com/problems/insert-delete-getrandom-o(1))| [Python](./python/380%20Insert%20Delete%20GetRandom%20O(1).py) [Java]() |Medium|| +|381|[Insert Delete GetRandom O(1) - Duplicates allowed](https://leetcode.com/problems/insert-delete-getrandom-o(1)---duplicates-allowed)| [Python](./python/381%20Insert%20Delete%20GetRandom%20O(1)%20-%20Duplicates%20allowed.py) [Java]() |Hard|| +|414|[Third Maximum Number](https://leetcode.com/problems/third-maximum-number)| [Python](./python/414%20Third%20Maximum%20Number.py) [Java]() |Easy|| +|442|[Find All Duplicates in an Array](https://leetcode.com/problems/find-all-duplicates-in-an-array)| [Python](./python/442%20Find%20All%20Duplicates%20in%20an%20Array.py) [Java]() |Medium|| +|448|[Find All Numbers Disappeared in an Array](https://leetcode.com/problems/find-all-numbers-disappeared-in-an-array)| [Python](./python/448%20Find%20All%20Numbers%20Disappeared%20in%20an%20Array.py) [Java]() |Easy|| +|485|[Max Consecutive Ones](https://leetcode.com/problems/max-consecutive-ones)| [Python](./python/485%20Max%20Consecutive%20Ones.py) [Java]() |Easy|| +|495|[Teemo Attacking](https://leetcode.com/problems/teemo-attacking)| [Python](./python/495%20Teemo%20Attacking.py) [Java]() |Medium|| +|531|[Lonely Pixel I](https://leetcode.com/problems/lonely-pixel-i)| [Python](./python/531%20Lonely%20Pixel%20I.py) [Java]() |Medium|| +|532|[K-diff Pairs in an Array](https://leetcode.com/problems/k-diff-pairs-in-an-array)| [Python](./python/532%20K-diff%20Pairs%20in%20an%20Array.py) [Java]() |Easy|| +|533|[Lonely Pixel II](https://leetcode.com/problems/lonely-pixel-ii)| [Python](./python/533%20Lonely%20Pixel%20II.py) [Java]() |Medium|| +|548|[Split Array with Equal Sum](https://leetcode.com/problems/split-array-with-equal-sum)| [Python](./python/548%20Split%20Array%20with%20Equal%20Sum.py) [Java]() |Medium|| +|560|[Subarray Sum Equals K](https://leetcode.com/problems/subarray-sum-equals-k)| [Python](./python/560%20Subarray%20Sum%20Equals%20K.py) [Java]() |Medium|| +|561|[Array Partition I](https://leetcode.com/problems/array-partition-i)| [Python](./python/561%20Array%20Partition%20I.py) [Java]() |Easy|| +|562|[Longest Line of Consecutive One in Matrix](https://leetcode.com/problems/longest-line-of-consecutive-one-in-matrix)| [Python](./python/562%20Longest%20Line%20of%20Consecutive%20One%20in%20Matrix.py) [Java]() |Medium|| +|566|[Reshape the Matrix](https://leetcode.com/problems/reshape-the-matrix)| [Python](./python/566%20Reshape%20the%20Matrix.py) [Java]() |Easy|| ## Hash Table | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|1|[Two Sum](https://leetcode.com/problems/two-sum)|[Python](./python/001 Two Sum.py) [Java]()|Easy|| -|3|[Longest Substring Without Repeating Characters](https://leetcode.com/problems/longest-substring-without-repeating-characters)|[Python](./python/003 Longest Substring Without Repeating Characters.py) [Java]()|Medium|| -|18|[4Sum](https://leetcode.com/problems/4sum)|[Python](./python/018 4Sum.py) [Java]()|Medium|| -|30|[Substring with Concatenation of All Words](https://leetcode.com/problems/substring-with-concatenation-of-all-words)|[Python](./python/030 Substring with Concatenation of All Words.py) [Java]()|Hard|| -|36|[Valid Sudoku](https://leetcode.com/problems/valid-sudoku)|[Python](./python/036 Valid Sudoku.py) [Java]()|Medium|| -|37|[Sudoku Solver](https://leetcode.com/problems/sudoku-solver)|[Python](./python/037 Sudoku Solver.py) [Java]()|Hard|| -|49|[Group Anagrams](https://leetcode.com/problems/group-anagrams)|[Python](./python/049 Group Anagrams.py) [Java]()|Medium|| -|76|[Minimum Window Substring](https://leetcode.com/problems/minimum-window-substring)|[Python](./python/076 Minimum Window Substring.py) [Java]()|Hard|| -|85|[Maximal Rectangle](https://leetcode.com/problems/maximal-rectangle)|[Python](./python/085 Maximal Rectangle.py) [Java]()|Hard|| -|94|[Binary Tree Inorder Traversal](https://leetcode.com/problems/binary-tree-inorder-traversal)|[Python](./python/094 Binary Tree Inorder Traversal.py) [Java]()|Medium|| -|136|[Single Number](https://leetcode.com/problems/single-number)|[Python](./python/136 Single Number.py) [Java]()|Easy|| -|138|[Copy List with Random Pointer](https://leetcode.com/problems/copy-list-with-random-pointer)|[Python](./python/138 Copy List with Random Pointer.py) [Java]()|Medium|| -|149|[Max Points on a Line](https://leetcode.com/problems/max-points-on-a-line)|[Python](./python/149 Max Points on a Line.py) [Java]()|Hard|| -|159|[Longest Substring with At Most Two Distinct Characters](https://leetcode.com/problems/longest-substring-with-at-most-two-distinct-characters)|[Python](./python/159 Longest Substring with At Most Two Distinct Characters.py) [Java]()|Hard|| -|166|[Fraction to Recurring Decimal](https://leetcode.com/problems/fraction-to-recurring-decimal)|[Python](./python/166 Fraction to Recurring Decimal.py) [Java]()|Medium|| -|170|[Two Sum III - Data structure design](https://leetcode.com/problems/two-sum-iii---data-structure-design)|[Python](./python/170 Two Sum III - Data structure design.py) [Java]()|Easy|| -|187|[Repeated DNA Sequences](https://leetcode.com/problems/repeated-dna-sequences)|[Python](./python/187 Repeated DNA Sequences.py) [Java]()|Medium|| -|202|[Happy Number](https://leetcode.com/problems/happy-number)|[Python](./python/202 Happy Number.py) [Java]()|Easy|| -|204|[Count Primes](https://leetcode.com/problems/count-primes)|[Python](./python/204 Count Primes.py) [Java]()|Easy|| -|205|[Isomorphic Strings](https://leetcode.com/problems/isomorphic-strings)|[Python](./python/205 Isomorphic Strings.py) [Java]()|Easy|| -|217|[Contains Duplicate](https://leetcode.com/problems/contains-duplicate)|[Python](./python/217 Contains Duplicate.py) [Java]()|Easy|| -|219|[Contains Duplicate II](https://leetcode.com/problems/contains-duplicate-ii)|[Python](./python/219 Contains Duplicate II.py) [Java]()|Easy|| -|242|[Valid Anagram](https://leetcode.com/problems/valid-anagram)|[Python](./python/242 Valid Anagram.py) [Java]()|Easy|| -|244|[Shortest Word Distance II](https://leetcode.com/problems/shortest-word-distance-ii)|[Python](./python/244 Shortest Word Distance II.py) [Java]()|Medium|| -|246|[Strobogrammatic Number](https://leetcode.com/problems/strobogrammatic-number)|[Python](./python/246 Strobogrammatic Number.py) [Java]()|Easy|| -|249|[Group Shifted Strings](https://leetcode.com/problems/group-shifted-strings)|[Python](./python/249 Group Shifted Strings.py) [Java]()|Medium|| -|266|[Palindrome Permutation](https://leetcode.com/problems/palindrome-permutation)|[Python](./python/266 Palindrome Permutation.py) [Java]()|Easy|| -|274|[H-Index](https://leetcode.com/problems/h-index)|[Python](./python/274 H-Index.py) [Java]()|Medium|| -|288|[Unique Word Abbreviation](https://leetcode.com/problems/unique-word-abbreviation)|[Python](./python/288 Unique Word Abbreviation.py) [Java]()|Medium|| -|290|[Word Pattern](https://leetcode.com/problems/word-pattern)|[Python](./python/290 Word Pattern.py) [Java]()|Easy|| -|299|[Bulls and Cows](https://leetcode.com/problems/bulls-and-cows)|[Python](./python/299 Bulls and Cows.py) [Java]()|Medium|| -|311|[Sparse Matrix Multiplication](https://leetcode.com/problems/sparse-matrix-multiplication)|[Python](./python/311 Sparse Matrix Multiplication.py) [Java]()|Medium|| -|314|[Binary Tree Vertical Order Traversal](https://leetcode.com/problems/binary-tree-vertical-order-traversal)|[Python](./python/314 Binary Tree Vertical Order Traversal.py) [Java]()|Medium|| -|325|[Maximum Size Subarray Sum Equals k](https://leetcode.com/problems/maximum-size-subarray-sum-equals-k)|[Python](./python/325 Maximum Size Subarray Sum Equals k.py) [Java]()|Medium|| -|336|[Palindrome Pairs](https://leetcode.com/problems/palindrome-pairs)|[Python](./python/336 Palindrome Pairs.py) [Java]()|Hard|| -|340|[Longest Substring with At Most K Distinct Characters](https://leetcode.com/problems/longest-substring-with-at-most-k-distinct-characters)|[Python](./python/340 Longest Substring with At Most K Distinct Characters.py) [Java]()|Hard|| -|347|[Top K Frequent Elements](https://leetcode.com/problems/top-k-frequent-elements)|[Python](./python/347 Top K Frequent Elements.py) [Java]()|Medium|| -|349|[Intersection of Two Arrays](https://leetcode.com/problems/intersection-of-two-arrays)|[Python](./python/349 Intersection of Two Arrays.py) [Java]()|Easy|| -|350|[Intersection of Two Arrays II](https://leetcode.com/problems/intersection-of-two-arrays-ii)|[Python](./python/350 Intersection of Two Arrays II.py) [Java]()|Easy|| -|355|[Design Twitter](https://leetcode.com/problems/design-twitter)|[Python](./python/355 Design Twitter.py) [Java]()|Medium|| -|356|[Line Reflection](https://leetcode.com/problems/line-reflection)|[Python](./python/356 Line Reflection.py) [Java]()|Medium|| -|358|[Rearrange String k Distance Apart](https://leetcode.com/problems/rearrange-string-k-distance-apart)|[Python](./python/358 Rearrange String k Distance Apart.py) [Java]()|Hard|| -|359|[Logger Rate Limiter](https://leetcode.com/problems/logger-rate-limiter)|[Python](./python/359 Logger Rate Limiter.py) [Java]()|Easy|| -|380|[Insert Delete GetRandom O(1)](https://leetcode.com/problems/insert-delete-getrandom-o(1))|[Python](./python/380 Insert Delete GetRandom O(1).py) [Java]()|Medium|| -|381|[Insert Delete GetRandom O(1) - Duplicates allowed](https://leetcode.com/problems/insert-delete-getrandom-o(1)---duplicates-allowed)|[Python](./python/381 Insert Delete GetRandom O(1) - Duplicates allowed.py) [Java]()|Hard|| -|389|[Find the Difference](https://leetcode.com/problems/find-the-difference)|[Python](./python/389 Find the Difference.py) [Java]()|Easy|| -|409|[Longest Palindrome](https://leetcode.com/problems/longest-palindrome)|[Python](./python/409 Longest Palindrome.py) [Java]()|Easy|| -|438|[Find All Anagrams in a String](https://leetcode.com/problems/find-all-anagrams-in-a-string)|[Python](./python/438 Find All Anagrams in a String.py) [Java]()|Easy|| -|447|[Number of Boomerangs](https://leetcode.com/problems/number-of-boomerangs)|[Python](./python/447 Number of Boomerangs.py) [Java]()|Easy|| -|451|[Sort Characters By Frequency](https://leetcode.com/problems/sort-characters-by-frequency)|[Python](./python/451 Sort Characters By Frequency.py) [Java]()|Medium|| -|454|[4Sum II](https://leetcode.com/problems/4sum-ii)|[Python](./python/454 4Sum II.py) [Java]()|Medium|| -|463|[Island Perimeter](https://leetcode.com/problems/island-perimeter)|[Python](./python/463 Island Perimeter.py) [Java]()|Easy|| -|500|[Keyboard Row](https://leetcode.com/problems/keyboard-row)|[Python](./python/500 Keyboard Row.py) [Java]()|Easy|| -|508|[Most Frequent Subtree Sum](https://leetcode.com/problems/most-frequent-subtree-sum)|[Python](./python/508 Most Frequent Subtree Sum.py) [Java]()|Medium|| -|525|[Contiguous Array](https://leetcode.com/problems/contiguous-array)|[Python](./python/525 Contiguous Array.py) [Java]()|Medium|| -|535|[Encode and Decode TinyURL](https://leetcode.com/problems/encode-and-decode-tinyurl)|[Python](./python/535 Encode and Decode TinyURL.py) [Java]()|Medium|| -|554|[Brick Wall](https://leetcode.com/problems/brick-wall)|[Python](./python/554 Brick Wall.py) [Java]()|Medium|| +|1|[Two Sum](https://leetcode.com/problems/two-sum)| [Python](./python/001%20Two%20Sum.py) [Java]() |Easy|| +|3|[Longest Substring Without Repeating Characters](https://leetcode.com/problems/longest-substring-without-repeating-characters)| [Python](./python/003%20Longest%20Substring%20Without%20Repeating%20Characters.py) [Java]() |Medium|| +|18|[4Sum](https://leetcode.com/problems/4sum)| [Python](./python/018%204Sum.py) [Java]() |Medium|| +|30|[Substring with Concatenation of All Words](https://leetcode.com/problems/substring-with-concatenation-of-all-words)| [Python](./python/030%20Substring%20with%20Concatenation%20of%20All%20Words.py) [Java]() |Hard|| +|36|[Valid Sudoku](https://leetcode.com/problems/valid-sudoku)| [Python](./python/036%20Valid%20Sudoku.py) [Java]() |Medium|| +|37|[Sudoku Solver](https://leetcode.com/problems/sudoku-solver)| [Python](./python/037%20Sudoku%20Solver.py) [Java]() |Hard|| +|49|[Group Anagrams](https://leetcode.com/problems/group-anagrams)| [Python](./python/049%20Group%20Anagrams.py) [Java]() |Medium|| +|76|[Minimum Window Substring](https://leetcode.com/problems/minimum-window-substring)| [Python](./python/076%20Minimum%20Window%20Substring.py) [Java]() |Hard|| +|85|[Maximal Rectangle](https://leetcode.com/problems/maximal-rectangle)| [Python](./python/085%20Maximal%20Rectangle.py) [Java]() |Hard|| +|94|[Binary Tree Inorder Traversal](https://leetcode.com/problems/binary-tree-inorder-traversal)| [Python](./python/094%20Binary%20Tree%20Inorder%20Traversal.py) [Java]() |Medium|| +|136|[Single Number](https://leetcode.com/problems/single-number)| [Python](./python/136%20Single%20Number.py) [Java]() |Easy|| +|138|[Copy List with Random Pointer](https://leetcode.com/problems/copy-list-with-random-pointer)| [Python](./python/138%20Copy%20List%20with%20Random%20Pointer.py) [Java]() |Medium|| +|149|[Max Points on a Line](https://leetcode.com/problems/max-points-on-a-line)| [Python](./python/149%20Max%20Points%20on%20a%20Line.py) [Java]() |Hard|| +|159|[Longest Substring with At Most Two Distinct Characters](https://leetcode.com/problems/longest-substring-with-at-most-two-distinct-characters)| [Python](./python/159%20Longest%20Substring%20with%20At%20Most%20Two%20Distinct%20Characters.py) [Java]() |Hard|| +|166|[Fraction to Recurring Decimal](https://leetcode.com/problems/fraction-to-recurring-decimal)| [Python](./python/166%20Fraction%20to%20Recurring%20Decimal.py) [Java]() |Medium|| +|170|[Two Sum III - Data structure design](https://leetcode.com/problems/two-sum-iii---data-structure-design)| [Python](./python/170%20Two%20Sum%20III%20-%20Data%20structure%20design.py) [Java]() |Easy|| +|187|[Repeated DNA Sequences](https://leetcode.com/problems/repeated-dna-sequences)| [Python](./python/187%20Repeated%20DNA%20Sequences.py) [Java]() |Medium|| +|202|[Happy Number](https://leetcode.com/problems/happy-number)| [Python](./python/202%20Happy%20Number.py) [Java]() |Easy|| +|204|[Count Primes](https://leetcode.com/problems/count-primes)| [Python](./python/204%20Count%20Primes.py) [Java]() |Easy|| +|205|[Isomorphic Strings](https://leetcode.com/problems/isomorphic-strings)| [Python](./python/205%20Isomorphic%20Strings.py) [Java]() |Easy|| +|217|[Contains Duplicate](https://leetcode.com/problems/contains-duplicate)| [Python](./python/217%20Contains%20Duplicate.py) [Java]() |Easy|| +|219|[Contains Duplicate II](https://leetcode.com/problems/contains-duplicate-ii)| [Python](./python/219%20Contains%20Duplicate%20II.py) [Java]() |Easy|| +|242|[Valid Anagram](https://leetcode.com/problems/valid-anagram)| [Python](./python/242%20Valid%20Anagram.py) [Java]() |Easy|| +|244|[Shortest Word Distance II](https://leetcode.com/problems/shortest-word-distance-ii)| [Python](./python/244%20Shortest%20Word%20Distance%20II.py) [Java]() |Medium|| +|246|[Strobogrammatic Number](https://leetcode.com/problems/strobogrammatic-number)| [Python](./python/246%20Strobogrammatic%20Number.py) [Java]() |Easy|| +|249|[Group Shifted Strings](https://leetcode.com/problems/group-shifted-strings)| [Python](./python/249%20Group%20Shifted%20Strings.py) [Java]() |Medium|| +|266|[Palindrome Permutation](https://leetcode.com/problems/palindrome-permutation)| [Python](./python/266%20Palindrome%20Permutation.py) [Java]() |Easy|| +|274|[H-Index](https://leetcode.com/problems/h-index)| [Python](./python/274%20H-Index.py) [Java]() |Medium|| +|288|[Unique Word Abbreviation](https://leetcode.com/problems/unique-word-abbreviation)| [Python](./python/288%20Unique%20Word%20Abbreviation.py) [Java]() |Medium|| +|290|[Word Pattern](https://leetcode.com/problems/word-pattern)| [Python](./python/290%20Word%20Pattern.py) [Java]() |Easy|| +|299|[Bulls and Cows](https://leetcode.com/problems/bulls-and-cows)| [Python](./python/299%20Bulls%20and%20Cows.py) [Java]() |Medium|| +|311|[Sparse Matrix Multiplication](https://leetcode.com/problems/sparse-matrix-multiplication)| [Python](./python/311%20Sparse%20Matrix%20Multiplication.py) [Java]() |Medium|| +|314|[Binary Tree Vertical Order Traversal](https://leetcode.com/problems/binary-tree-vertical-order-traversal)| [Python](./python/314%20Binary%20Tree%20Vertical%20Order%20Traversal.py) [Java]() |Medium|| +|325|[Maximum Size Subarray Sum Equals k](https://leetcode.com/problems/maximum-size-subarray-sum-equals-k)| [Python](./python/325%20Maximum%20Size%20Subarray%20Sum%20Equals%20k.py) [Java]() |Medium|| +|336|[Palindrome Pairs](https://leetcode.com/problems/palindrome-pairs)| [Python](./python/336%20Palindrome%20Pairs.py) [Java]() |Hard|| +|340|[Longest Substring with At Most K Distinct Characters](https://leetcode.com/problems/longest-substring-with-at-most-k-distinct-characters)| [Python](./python/340%20Longest%20Substring%20with%20At%20Most%20K%20Distinct%20Characters.py) [Java]() |Hard|| +|347|[Top K Frequent Elements](https://leetcode.com/problems/top-k-frequent-elements)| [Python](./python/347%20Top%20K%20Frequent%20Elements.py) [Java]() |Medium|| +|349|[Intersection of Two Arrays](https://leetcode.com/problems/intersection-of-two-arrays)| [Python](./python/349%20Intersection%20of%20Two%20Arrays.py) [Java]() |Easy|| +|350|[Intersection of Two Arrays II](https://leetcode.com/problems/intersection-of-two-arrays-ii)| [Python](./python/350%20Intersection%20of%20Two%20Arrays%20II.py) [Java]() |Easy|| +|355|[Design Twitter](https://leetcode.com/problems/design-twitter)| [Python](./python/355%20Design%20Twitter.py) [Java]() |Medium|| +|356|[Line Reflection](https://leetcode.com/problems/line-reflection)| [Python](./python/356%20Line%20Reflection.py) [Java]() |Medium|| +|358|[Rearrange String k Distance Apart](https://leetcode.com/problems/rearrange-string-k-distance-apart)| [Python](./python/358%20Rearrange%20String%20k%20Distance%20Apart.py) [Java]() |Hard|| +|359|[Logger Rate Limiter](https://leetcode.com/problems/logger-rate-limiter)| [Python](./python/359%20Logger%20Rate%20Limiter.py) [Java]() |Easy|| +|380|[Insert Delete GetRandom O(1)](https://leetcode.com/problems/insert-delete-getrandom-o(1))| [Python](./python/380%20Insert%20Delete%20GetRandom%20O(1).py) [Java]() |Medium|| +|381|[Insert Delete GetRandom O(1) - Duplicates allowed](https://leetcode.com/problems/insert-delete-getrandom-o(1)---duplicates-allowed)| [Python](./python/381%20Insert%20Delete%20GetRandom%20O(1)%20-%20Duplicates%20allowed.py) [Java]() |Hard|| +|389|[Find the Difference](https://leetcode.com/problems/find-the-difference)| [Python](./python/389%20Find%20the%20Difference.py) [Java]() |Easy|| +|409|[Longest Palindrome](https://leetcode.com/problems/longest-palindrome)| [Python](./python/409%20Longest%20Palindrome.py) [Java]() |Easy|| +|438|[Find All Anagrams in a String](https://leetcode.com/problems/find-all-anagrams-in-a-string)| [Python](./python/438%20Find%20All%20Anagrams%20in%20a%20String.py) [Java]() |Easy|| +|447|[Number of Boomerangs](https://leetcode.com/problems/number-of-boomerangs)| [Python](./python/447%20Number%20of%20Boomerangs.py) [Java]() |Easy|| +|451|[Sort Characters By Frequency](https://leetcode.com/problems/sort-characters-by-frequency)| [Python](./python/451%20Sort%20Characters%20By%20Frequency.py) [Java]() |Medium|| +|454|[4Sum II](https://leetcode.com/problems/4sum-ii)| [Python](./python/454%204Sum%20II.py) [Java]() |Medium|| +|463|[Island Perimeter](https://leetcode.com/problems/island-perimeter)| [Python](./python/463%20Island%20Perimeter.py) [Java]() |Easy|| +|500|[Keyboard Row](https://leetcode.com/problems/keyboard-row)| [Python](./python/500%20Keyboard%20Row.py) [Java]() |Easy|| +|508|[Most Frequent Subtree Sum](https://leetcode.com/problems/most-frequent-subtree-sum)| [Python](./python/508%20Most%20Frequent%20Subtree%20Sum.py) [Java]() |Medium|| +|525|[Contiguous Array](https://leetcode.com/problems/contiguous-array)| [Python](./python/525%20Contiguous%20Array.py) [Java]() |Medium|| +|535|[Encode and Decode TinyURL](https://leetcode.com/problems/encode-and-decode-tinyurl)| [Python](./python/535%20Encode%20and%20Decode%20TinyURL.py) [Java]() |Medium|| +|554|[Brick Wall](https://leetcode.com/problems/brick-wall)| [Python](./python/554%20Brick%20Wall.py) [Java]() |Medium|| ## Linked List | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|2|[Add Two Numbers](https://leetcode.com/problems/add-two-numbers)|[Python](./python/002 Add Two Numbers.py) [Java]()|Medium|| -|19|[Remove Nth Node From End of List](https://leetcode.com/problems/remove-nth-node-from-end-of-list)|[Python](./python/019 Remove Nth Node From End of List.py) [Java]()|Medium|| -|21|[Merge Two Sorted Lists](https://leetcode.com/problems/merge-two-sorted-lists)|[Python](./python/021 Merge Two Sorted Lists.py) [Java]()|Easy|| -|23|[Merge k Sorted Lists](https://leetcode.com/problems/merge-k-sorted-lists)|[Python](./python/023 Merge k Sorted Lists.py) [Java]()|Hard|| -|24|[Swap Nodes in Pairs](https://leetcode.com/problems/swap-nodes-in-pairs)|[Python](./python/024 Swap Nodes in Pairs.py) [Java]()|Medium|| -|25|[Reverse Nodes in k-Group](https://leetcode.com/problems/reverse-nodes-in-k-group)|[Python](./python/025 Reverse Nodes in k-Group.py) [Java]()|Hard|| -|61|[Rotate List](https://leetcode.com/problems/rotate-list)|[Python](./python/061 Rotate List.py) [Java]()|Medium|| -|82|[Remove Duplicates from Sorted List II](https://leetcode.com/problems/remove-duplicates-from-sorted-list-ii)|[Python](./python/082 Remove Duplicates from Sorted List II.py) [Java]()|Medium|| -|83|[Remove Duplicates from Sorted List](https://leetcode.com/problems/remove-duplicates-from-sorted-list)|[Python](./python/083 Remove Duplicates from Sorted List.py) [Java]()|Easy|| -|86|[Partition List](https://leetcode.com/problems/partition-list)|[Python](./python/086 Partition List.py) [Java]()|Medium|| -|92|[Reverse Linked List II](https://leetcode.com/problems/reverse-linked-list-ii)|[Python](./python/092 Reverse Linked List II.py) [Java]()|Medium|| -|109|[Convert Sorted List to Binary Search Tree](https://leetcode.com/problems/convert-sorted-list-to-binary-search-tree)|[Python](./python/109 Convert Sorted List to Binary Search Tree.py) [Java]()|Medium|| -|138|[Copy List with Random Pointer](https://leetcode.com/problems/copy-list-with-random-pointer)|[Python](./python/138 Copy List with Random Pointer.py) [Java]()|Medium|| -|141|[Linked List Cycle](https://leetcode.com/problems/linked-list-cycle)|[Python](./python/141 Linked List Cycle.py) [Java]()|Easy|| -|142|[Linked List Cycle II](https://leetcode.com/problems/linked-list-cycle-ii)|[Python](./python/142 Linked List Cycle II.py) [Java]()|Medium|| -|143|[Reorder List](https://leetcode.com/problems/reorder-list)|[Python](./python/143 Reorder List.py) [Java]()|Medium|| -|147|[Insertion Sort List](https://leetcode.com/problems/insertion-sort-list)|[Python](./python/147 Insertion Sort List.py) [Java]()|Medium|| -|148|[Sort List](https://leetcode.com/problems/sort-list)|[Python](./python/148 Sort List.py) [Java]()|Medium|| -|160|[Intersection of Two Linked Lists](https://leetcode.com/problems/intersection-of-two-linked-lists)|[Python](./python/160 Intersection of Two Linked Lists.py) [Java]()|Easy|| -|203|[Remove Linked List Elements](https://leetcode.com/problems/remove-linked-list-elements)|[Python](./python/203 Remove Linked List Elements.py) [Java]()|Easy|| -|206|[Reverse Linked List](https://leetcode.com/problems/reverse-linked-list)|[Python](./python/206 Reverse Linked List.py) [Java]()|Easy|| -|234|[Palindrome Linked List](https://leetcode.com/problems/palindrome-linked-list)|[Python](./python/234 Palindrome Linked List.py) [Java]()|Easy|| -|237|[Delete Node in a Linked List](https://leetcode.com/problems/delete-node-in-a-linked-list)|[Python](./python/237 Delete Node in a Linked List.py) [Java]()|Easy|| -|328|[Odd Even Linked List](https://leetcode.com/problems/odd-even-linked-list)|[Python](./python/328 Odd Even Linked List.py) [Java]()|Medium|| -|369|[Plus One Linked List](https://leetcode.com/problems/plus-one-linked-list)|[Python](./python/369 Plus One Linked List.py) [Java]()|Medium|| -|379|[Design Phone Directory](https://leetcode.com/problems/design-phone-directory)|[Python](./python/379 Design Phone Directory.py) [Java]()|Medium|| -|445|[Add Two Numbers II](https://leetcode.com/problems/add-two-numbers-ii)|[Python](./python/445 Add Two Numbers II.py) [Java]()|Medium|| +|2|[Add Two Numbers](https://leetcode.com/problems/add-two-numbers)| [Python](./python/002%20Add%20Two%20Numbers.py) [Java]() |Medium|| +|19|[Remove Nth Node From End of List](https://leetcode.com/problems/remove-nth-node-from-end-of-list)| [Python](./python/019%20Remove%20Nth%20Node%20From%20End%20of%20List.py) [Java]() |Medium|| +|21|[Merge Two Sorted Lists](https://leetcode.com/problems/merge-two-sorted-lists)| [Python](./python/021%20Merge%20Two%20Sorted%20Lists.py) [Java]() |Easy|| +|23|[Merge k Sorted Lists](https://leetcode.com/problems/merge-k-sorted-lists)| [Python](./python/023%20Merge%20k%20Sorted%20Lists.py) [Java]() |Hard|| +|24|[Swap Nodes in Pairs](https://leetcode.com/problems/swap-nodes-in-pairs)| [Python](./python/024%20Swap%20Nodes%20in%20Pairs.py) [Java]() |Medium|| +|25|[Reverse Nodes in k-Group](https://leetcode.com/problems/reverse-nodes-in-k-group)| [Python](./python/025%20Reverse%20Nodes%20in%20k-Group.py) [Java]() |Hard|| +|61|[Rotate List](https://leetcode.com/problems/rotate-list)| [Python](./python/061%20Rotate%20List.py) [Java]() |Medium|| +|82|[Remove Duplicates from Sorted List II](https://leetcode.com/problems/remove-duplicates-from-sorted-list-ii)| [Python](./python/082%20Remove%20Duplicates%20from%20Sorted%20List%20II.py) [Java]() |Medium|| +|83|[Remove Duplicates from Sorted List](https://leetcode.com/problems/remove-duplicates-from-sorted-list)| [Python](./python/083%20Remove%20Duplicates%20from%20Sorted%20List.py) [Java]() |Easy|| +|86|[Partition List](https://leetcode.com/problems/partition-list)| [Python](./python/086%20Partition%20List.py) [Java]() |Medium|| +|92|[Reverse Linked List II](https://leetcode.com/problems/reverse-linked-list-ii)| [Python](./python/092%20Reverse%20Linked%20List%20II.py) [Java]() |Medium|| +|109|[Convert Sorted List to Binary Search Tree](https://leetcode.com/problems/convert-sorted-list-to-binary-search-tree)| [Python](./python/109%20Convert%20Sorted%20List%20to%20Binary%20Search%20Tree.py) [Java]() |Medium|| +|138|[Copy List with Random Pointer](https://leetcode.com/problems/copy-list-with-random-pointer)| [Python](./python/138%20Copy%20List%20with%20Random%20Pointer.py) [Java]() |Medium|| +|141|[Linked List Cycle](https://leetcode.com/problems/linked-list-cycle)| [Python](./python/141%20Linked%20List%20Cycle.py) [Java]() |Easy|| +|142|[Linked List Cycle II](https://leetcode.com/problems/linked-list-cycle-ii)| [Python](./python/142%20Linked%20List%20Cycle%20II.py) [Java]() |Medium|| +|143|[Reorder List](https://leetcode.com/problems/reorder-list)| [Python](./python/143%20Reorder%20List.py) [Java]() |Medium|| +|147|[Insertion Sort List](https://leetcode.com/problems/insertion-sort-list)| [Python](./python/147%20Insertion%20Sort%20List.py) [Java]() |Medium|| +|148|[Sort List](https://leetcode.com/problems/sort-list)| [Python](./python/148%20Sort%20List.py) [Java]() |Medium|| +|160|[Intersection of Two Linked Lists](https://leetcode.com/problems/intersection-of-two-linked-lists)| [Python](./python/160%20Intersection%20of%20Two%20Linked%20Lists.py) [Java]() |Easy|| +|203|[Remove Linked List Elements](https://leetcode.com/problems/remove-linked-list-elements)| [Python](./python/203%20Remove%20Linked%20List%20Elements.py) [Java]() |Easy|| +|206|[Reverse Linked List](https://leetcode.com/problems/reverse-linked-list)| [Python](./python/206%20Reverse%20Linked%20List.py) [Java]() |Easy|| +|234|[Palindrome Linked List](https://leetcode.com/problems/palindrome-linked-list)| [Python](./python/234%20Palindrome%20Linked%20List.py) [Java]() |Easy|| +|237|[Delete Node in a Linked List](https://leetcode.com/problems/delete-node-in-a-linked-list)| [Python](./python/237%20Delete%20Node%20in%20a%20Linked%20List.py) [Java]() |Easy|| +|328|[Odd Even Linked List](https://leetcode.com/problems/odd-even-linked-list)| [Python](./python/328%20Odd%20Even%20Linked%20List.py) [Java]() |Medium|| +|369|[Plus One Linked List](https://leetcode.com/problems/plus-one-linked-list)| [Python](./python/369%20Plus%20One%20Linked%20List.py) [Java]() |Medium|| +|379|[Design Phone Directory](https://leetcode.com/problems/design-phone-directory)| [Python](./python/379%20Design%20Phone%20Directory.py) [Java]() |Medium|| +|445|[Add Two Numbers II](https://leetcode.com/problems/add-two-numbers-ii)| [Python](./python/445%20Add%20Two%20Numbers%20II.py) [Java]() |Medium|| ## Math | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|2|[Add Two Numbers](https://leetcode.com/problems/add-two-numbers)|[Python](./python/002 Add Two Numbers.py) [Java]()|Medium|| -|7|[Reverse Integer](https://leetcode.com/problems/reverse-integer)|[Python](./python/007 Reverse Integer.py) [Java]()|Easy|| -|8|[String to Integer (atoi)](https://leetcode.com/problems/string-to-integer-(atoi))|[Python](./python/008 String to Integer (atoi).py) [Java]()|Medium|| -|9|[Palindrome Number](https://leetcode.com/problems/palindrome-number)|[Python](./python/009 Palindrome Number.py) [Java]()|Easy|| -|12|[Integer to Roman](https://leetcode.com/problems/integer-to-roman)|[Python](./python/012 Integer to Roman.py) [Java]()|Medium|| -|13|[Roman to Integer](https://leetcode.com/problems/roman-to-integer)|[Python](./python/013 Roman to Integer.py) [Java]()|Easy|| -|29|[Divide Two Integers](https://leetcode.com/problems/divide-two-integers)|[Python](./python/029 Divide Two Integers.py) [Java]()|Medium|| -|43|[Multiply Strings](https://leetcode.com/problems/multiply-strings)|[Python](./python/043 Multiply Strings.py) [Java]()|Medium|| -|50|[Pow(x, n)](https://leetcode.com/problems/pow(x,-n))|[Python](./python/050 Pow(x, n).py) [Java]()|Medium|| -|60|[Permutation Sequence](https://leetcode.com/problems/permutation-sequence)|[Python](./python/060 Permutation Sequence.py) [Java]()|Medium|| -|65|[Valid Number](https://leetcode.com/problems/valid-number)|[Python](./python/065 Valid Number.py) [Java]()|Hard|| -|66|[Plus One](https://leetcode.com/problems/plus-one)|[Python](./python/066 Plus One.py) [Java]()|Easy|| -|67|[Add Binary](https://leetcode.com/problems/add-binary)|[Python](./python/067 Add Binary.py) [Java]()|Easy|| -|69|[Sqrt(x)](https://leetcode.com/problems/sqrt(x))|[Python](./python/069 Sqrt(x).py) [Java]()|Easy|| -|149|[Max Points on a Line](https://leetcode.com/problems/max-points-on-a-line)|[Python](./python/149 Max Points on a Line.py) [Java]()|Hard|| -|166|[Fraction to Recurring Decimal](https://leetcode.com/problems/fraction-to-recurring-decimal)|[Python](./python/166 Fraction to Recurring Decimal.py) [Java]()|Medium|| -|168|[Excel Sheet Column Title](https://leetcode.com/problems/excel-sheet-column-title)|[Python](./python/168 Excel Sheet Column Title.py) [Java]()|Easy|| -|171|[Excel Sheet Column Number](https://leetcode.com/problems/excel-sheet-column-number)|[Python](./python/171 Excel Sheet Column Number.py) [Java]()|Easy|| -|172|[Factorial Trailing Zeroes](https://leetcode.com/problems/factorial-trailing-zeroes)|[Python](./python/172 Factorial Trailing Zeroes.py) [Java]()|Easy|| -|202|[Happy Number](https://leetcode.com/problems/happy-number)|[Python](./python/202 Happy Number.py) [Java]()|Easy|| -|204|[Count Primes](https://leetcode.com/problems/count-primes)|[Python](./python/204 Count Primes.py) [Java]()|Easy|| -|223|[Rectangle Area](https://leetcode.com/problems/rectangle-area)|[Python](./python/223 Rectangle Area.py) [Java]()|Medium|| -|224|[Basic Calculator](https://leetcode.com/problems/basic-calculator)|[Python](./python/224 Basic Calculator.py) [Java]()|Hard|| -|231|[Power of Two](https://leetcode.com/problems/power-of-two)|[Python](./python/231 Power of Two.py) [Java]()|Easy|| -|233|[Number of Digit One](https://leetcode.com/problems/number-of-digit-one)|[Python](./python/233 Number of Digit One.py) [Java]()|Hard|| -|246|[Strobogrammatic Number](https://leetcode.com/problems/strobogrammatic-number)|[Python](./python/246 Strobogrammatic Number.py) [Java]()|Easy|| -|247|[Strobogrammatic Number II](https://leetcode.com/problems/strobogrammatic-number-ii)|[Python](./python/247 Strobogrammatic Number II.py) [Java]()|Medium|| -|248|[Strobogrammatic Number III](https://leetcode.com/problems/strobogrammatic-number-iii)|[Python](./python/248 Strobogrammatic Number III.py) [Java]()|Hard|| -|258|[Add Digits](https://leetcode.com/problems/add-digits)|[Python](./python/258 Add Digits.py) [Java]()|Easy|| -|263|[Ugly Number](https://leetcode.com/problems/ugly-number)|[Python](./python/263 Ugly Number.py) [Java]()|Easy|| -|264|[Ugly Number II](https://leetcode.com/problems/ugly-number-ii)|[Python](./python/264 Ugly Number II.py) [Java]()|Medium|| -|268|[Missing Number](https://leetcode.com/problems/missing-number)|[Python](./python/268 Missing Number.py) [Java]()|Easy|| -|273|[Integer to English Words](https://leetcode.com/problems/integer-to-english-words)|[Python](./python/273 Integer to English Words.py) [Java]()|Hard|| -|279|[Perfect Squares](https://leetcode.com/problems/perfect-squares)|[Python](./python/279 Perfect Squares.py) [Java]()|Medium|| -|296|[Best Meeting Point](https://leetcode.com/problems/best-meeting-point)|[Python](./python/296 Best Meeting Point.py) [Java]()|Hard|| -|313|[Super Ugly Number](https://leetcode.com/problems/super-ugly-number)|[Python](./python/313 Super Ugly Number.py) [Java]()|Medium|| -|319|[Bulb Switcher](https://leetcode.com/problems/bulb-switcher)|[Python](./python/319 Bulb Switcher.py) [Java]()|Medium|| -|326|[Power of Three](https://leetcode.com/problems/power-of-three)|[Python](./python/326 Power of Three.py) [Java]()|Easy|| -|335|[Self Crossing](https://leetcode.com/problems/self-crossing)|[Python](./python/335 Self Crossing.py) [Java]()|Hard|| -|343|[Integer Break](https://leetcode.com/problems/integer-break)|[Python](./python/343 Integer Break.py) [Java]()|Medium|| -|356|[Line Reflection](https://leetcode.com/problems/line-reflection)|[Python](./python/356 Line Reflection.py) [Java]()|Medium|| -|357|[Count Numbers with Unique Digits](https://leetcode.com/problems/count-numbers-with-unique-digits)|[Python](./python/357 Count Numbers with Unique Digits.py) [Java]()|Medium|| -|360|[Sort Transformed Array](https://leetcode.com/problems/sort-transformed-array)|[Python](./python/360 Sort Transformed Array.py) [Java]()|Medium|| -|365|[Water and Jug Problem](https://leetcode.com/problems/water-and-jug-problem)|[Python](./python/365 Water and Jug Problem.py) [Java]()|Medium|| -|367|[Valid Perfect Square](https://leetcode.com/problems/valid-perfect-square)|[Python](./python/367 Valid Perfect Square.py) [Java]()|Easy|| -|368|[Largest Divisible Subset](https://leetcode.com/problems/largest-divisible-subset)|[Python](./python/368 Largest Divisible Subset.py) [Java]()|Medium|| -|372|[Super Pow](https://leetcode.com/problems/super-pow)|[Python](./python/372 Super Pow.py) [Java]()|Medium|| -|396|[Rotate Function](https://leetcode.com/problems/rotate-function)|[Python](./python/396 Rotate Function.py) [Java]()|Medium|| -|397|[Integer Replacement](https://leetcode.com/problems/integer-replacement)|[Python](./python/397 Integer Replacement.py) [Java]()|Medium|| -|400|[Nth Digit](https://leetcode.com/problems/nth-digit)|[Python](./python/400 Nth Digit.py) [Java]()|Easy|| -|413|[Arithmetic Slices](https://leetcode.com/problems/arithmetic-slices)|[Python](./python/413 Arithmetic Slices.py) [Java]()|Medium|| -|415|[Add Strings](https://leetcode.com/problems/add-strings)|[Python](./python/415 Add Strings.py) [Java]()|Easy|| -|423|[Reconstruct Original Digits from English](https://leetcode.com/problems/reconstruct-original-digits-from-english)|[Python](./python/423 Reconstruct Original Digits from English.py) [Java]()|Medium|| -|441|[Arranging Coins](https://leetcode.com/problems/arranging-coins)|[Python](./python/441 Arranging Coins.py) [Java]()|Easy|| -|453|[Minimum Moves to Equal Array Elements](https://leetcode.com/problems/minimum-moves-to-equal-array-elements)|[Python](./python/453 Minimum Moves to Equal Array Elements.py) [Java]()|Easy|| -|462|[Minimum Moves to Equal Array Elements II](https://leetcode.com/problems/minimum-moves-to-equal-array-elements-ii)|[Python](./python/462 Minimum Moves to Equal Array Elements II.py) [Java]()|Medium|| -|469|[Convex Polygon](https://leetcode.com/problems/convex-polygon)|[Python](./python/469 Convex Polygon.py) [Java]()|Medium|| -|483|[Smallest Good Base](https://leetcode.com/problems/smallest-good-base)|[Python](./python/483 Smallest Good Base.py) [Java]()|Hard|| -|507|[Perfect Number](https://leetcode.com/problems/perfect-number)|[Python](./python/507 Perfect Number.py) [Java]()|Easy|| -|517|[Super Washing Machines](https://leetcode.com/problems/super-washing-machines)|[Python](./python/517 Super Washing Machines.py) [Java]()|Hard|| -|523|[Continuous Subarray Sum](https://leetcode.com/problems/continuous-subarray-sum)|[Python](./python/523 Continuous Subarray Sum.py) [Java]()|Medium|| -|535|[Encode and Decode TinyURL](https://leetcode.com/problems/encode-and-decode-tinyurl)|[Python](./python/535 Encode and Decode TinyURL.py) [Java]()|Medium|| -|537|[Complex Number Multiplication](https://leetcode.com/problems/complex-number-multiplication)|[Python](./python/537 Complex Number Multiplication.py) [Java]()|Medium|| -|553|[Optimal Division](https://leetcode.com/problems/optimal-division)|[Python](./python/553 Optimal Division.py) [Java]()|Medium|| +|2|[Add Two Numbers](https://leetcode.com/problems/add-two-numbers)| [Python](./python/002%20Add%20Two%20Numbers.py) [Java]() |Medium|| +|7|[Reverse Integer](https://leetcode.com/problems/reverse-integer)| [Python](./python/007%20Reverse%20Integer.py) [Java]() |Easy|| +|8|[String to Integer (atoi)](https://leetcode.com/problems/string-to-integer-(atoi))| [Python](./python/008%20String%20to%20Integer%20(atoi).py) [Java]() |Medium|| +|9|[Palindrome Number](https://leetcode.com/problems/palindrome-number)| [Python](./python/009%20Palindrome%20Number.py) [Java]() |Easy|| +|12|[Integer to Roman](https://leetcode.com/problems/integer-to-roman)| [Python](./python/012%20Integer%20to%20Roman.py) [Java]() |Medium|| +|13|[Roman to Integer](https://leetcode.com/problems/roman-to-integer)| [Python](./python/013%20Roman%20to%20Integer.py) [Java]() |Easy|| +|29|[Divide Two Integers](https://leetcode.com/problems/divide-two-integers)| [Python](./python/029%20Divide%20Two%20Integers.py) [Java]() |Medium|| +|43|[Multiply Strings](https://leetcode.com/problems/multiply-strings)| [Python](./python/043%20Multiply%20Strings.py) [Java]() |Medium|| +|50|[Pow(x, n)](https://leetcode.com/problems/pow(x,-n))| [Python](./python/050%20Pow(x,%20n).py) [Java]() |Medium|| +|60|[Permutation Sequence](https://leetcode.com/problems/permutation-sequence)| [Python](./python/060%20Permutation%20Sequence.py) [Java]() |Medium|| +|65|[Valid Number](https://leetcode.com/problems/valid-number)| [Python](./python/065%20Valid%20Number.py) [Java]() |Hard|| +|66|[Plus One](https://leetcode.com/problems/plus-one)| [Python](./python/066%20Plus%20One.py) [Java]() |Easy|| +|67|[Add Binary](https://leetcode.com/problems/add-binary)| [Python](./python/067%20Add%20Binary.py) [Java]() |Easy|| +|69|[Sqrt(x)](https://leetcode.com/problems/sqrt(x))| [Python](./python/069%20Sqrt(x).py) [Java]() |Easy|| +|149|[Max Points on a Line](https://leetcode.com/problems/max-points-on-a-line)| [Python](./python/149%20Max%20Points%20on%20a%20Line.py) [Java]() |Hard|| +|166|[Fraction to Recurring Decimal](https://leetcode.com/problems/fraction-to-recurring-decimal)| [Python](./python/166%20Fraction%20to%20Recurring%20Decimal.py) [Java]() |Medium|| +|168|[Excel Sheet Column Title](https://leetcode.com/problems/excel-sheet-column-title)| [Python](./python/168%20Excel%20Sheet%20Column%20Title.py) [Java]() |Easy|| +|171|[Excel Sheet Column Number](https://leetcode.com/problems/excel-sheet-column-number)| [Python](./python/171%20Excel%20Sheet%20Column%20Number.py) [Java]() |Easy|| +|172|[Factorial Trailing Zeroes](https://leetcode.com/problems/factorial-trailing-zeroes)| [Python](./python/172%20Factorial%20Trailing%20Zeroes.py) [Java]() |Easy|| +|202|[Happy Number](https://leetcode.com/problems/happy-number)| [Python](./python/202%20Happy%20Number.py) [Java]() |Easy|| +|204|[Count Primes](https://leetcode.com/problems/count-primes)| [Python](./python/204%20Count%20Primes.py) [Java]() |Easy|| +|223|[Rectangle Area](https://leetcode.com/problems/rectangle-area)| [Python](./python/223%20Rectangle%20Area.py) [Java]() |Medium|| +|224|[Basic Calculator](https://leetcode.com/problems/basic-calculator)| [Python](./python/224%20Basic%20Calculator.py) [Java]() |Hard|| +|231|[Power of Two](https://leetcode.com/problems/power-of-two)| [Python](./python/231%20Power%20of%20Two.py) [Java]() |Easy|| +|233|[Number of Digit One](https://leetcode.com/problems/number-of-digit-one)| [Python](./python/233%20Number%20of%20Digit%20One.py) [Java]() |Hard|| +|246|[Strobogrammatic Number](https://leetcode.com/problems/strobogrammatic-number)| [Python](./python/246%20Strobogrammatic%20Number.py) [Java]() |Easy|| +|247|[Strobogrammatic Number II](https://leetcode.com/problems/strobogrammatic-number-ii)| [Python](./python/247%20Strobogrammatic%20Number%20II.py) [Java]() |Medium|| +|248|[Strobogrammatic Number III](https://leetcode.com/problems/strobogrammatic-number-iii)| [Python](./python/248%20Strobogrammatic%20Number%20III.py) [Java]() |Hard|| +|258|[Add Digits](https://leetcode.com/problems/add-digits)| [Python](./python/258%20Add%20Digits.py) [Java]() |Easy|| +|263|[Ugly Number](https://leetcode.com/problems/ugly-number)| [Python](./python/263%20Ugly%20Number.py) [Java]() |Easy|| +|264|[Ugly Number II](https://leetcode.com/problems/ugly-number-ii)| [Python](./python/264%20Ugly%20Number%20II.py) [Java]() |Medium|| +|268|[Missing Number](https://leetcode.com/problems/missing-number)| [Python](./python/268%20Missing%20Number.py) [Java]() |Easy|| +|273|[Integer to English Words](https://leetcode.com/problems/integer-to-english-words)| [Python](./python/273%20Integer%20to%20English%20Words.py) [Java]() |Hard|| +|279|[Perfect Squares](https://leetcode.com/problems/perfect-squares)| [Python](./python/279%20Perfect%20Squares.py) [Java]() |Medium|| +|296|[Best Meeting Point](https://leetcode.com/problems/best-meeting-point)| [Python](./python/296%20Best%20Meeting%20Point.py) [Java]() |Hard|| +|313|[Super Ugly Number](https://leetcode.com/problems/super-ugly-number)| [Python](./python/313%20Super%20Ugly%20Number.py) [Java]() |Medium|| +|319|[Bulb Switcher](https://leetcode.com/problems/bulb-switcher)| [Python](./python/319%20Bulb%20Switcher.py) [Java]() |Medium|| +|326|[Power of Three](https://leetcode.com/problems/power-of-three)| [Python](./python/326%20Power%20of%20Three.py) [Java]() |Easy|| +|335|[Self Crossing](https://leetcode.com/problems/self-crossing)| [Python](./python/335%20Self%20Crossing.py) [Java]() |Hard|| +|343|[Integer Break](https://leetcode.com/problems/integer-break)| [Python](./python/343%20Integer%20Break.py) [Java]() |Medium|| +|356|[Line Reflection](https://leetcode.com/problems/line-reflection)| [Python](./python/356%20Line%20Reflection.py) [Java]() |Medium|| +|357|[Count Numbers with Unique Digits](https://leetcode.com/problems/count-numbers-with-unique-digits)| [Python](./python/357%20Count%20Numbers%20with%20Unique%20Digits.py) [Java]() |Medium|| +|360|[Sort Transformed Array](https://leetcode.com/problems/sort-transformed-array)| [Python](./python/360%20Sort%20Transformed%20Array.py) [Java]() |Medium|| +|365|[Water and Jug Problem](https://leetcode.com/problems/water-and-jug-problem)| [Python](./python/365%20Water%20and%20Jug%20Problem.py) [Java]() |Medium|| +|367|[Valid Perfect Square](https://leetcode.com/problems/valid-perfect-square)| [Python](./python/367%20Valid%20Perfect%20Square.py) [Java]() |Easy|| +|368|[Largest Divisible Subset](https://leetcode.com/problems/largest-divisible-subset)| [Python](./python/368%20Largest%20Divisible%20Subset.py) [Java]() |Medium|| +|372|[Super Pow](https://leetcode.com/problems/super-pow)| [Python](./python/372%20Super%20Pow.py) [Java]() |Medium|| +|396|[Rotate Function](https://leetcode.com/problems/rotate-function)| [Python](./python/396%20Rotate%20Function.py) [Java]() |Medium|| +|397|[Integer Replacement](https://leetcode.com/problems/integer-replacement)| [Python](./python/397%20Integer%20Replacement.py) [Java]() |Medium|| +|400|[Nth Digit](https://leetcode.com/problems/nth-digit)| [Python](./python/400%20Nth%20Digit.py) [Java]() |Easy|| +|413|[Arithmetic Slices](https://leetcode.com/problems/arithmetic-slices)| [Python](./python/413%20Arithmetic%20Slices.py) [Java]() |Medium|| +|415|[Add Strings](https://leetcode.com/problems/add-strings)| [Python](./python/415%20Add%20Strings.py) [Java]() |Easy|| +|423|[Reconstruct Original Digits from English](https://leetcode.com/problems/reconstruct-original-digits-from-english)| [Python](./python/423%20Reconstruct%20Original%20Digits%20from%20English.py) [Java]() |Medium|| +|441|[Arranging Coins](https://leetcode.com/problems/arranging-coins)| [Python](./python/441%20Arranging%20Coins.py) [Java]() |Easy|| +|453|[Minimum Moves to Equal Array Elements](https://leetcode.com/problems/minimum-moves-to-equal-array-elements)| [Python](./python/453%20Minimum%20Moves%20to%20Equal%20Array%20Elements.py) [Java]() |Easy|| +|462|[Minimum Moves to Equal Array Elements II](https://leetcode.com/problems/minimum-moves-to-equal-array-elements-ii)| [Python](./python/462%20Minimum%20Moves%20to%20Equal%20Array%20Elements%20II.py) [Java]() |Medium|| +|469|[Convex Polygon](https://leetcode.com/problems/convex-polygon)| [Python](./python/469%20Convex%20Polygon.py) [Java]() |Medium|| +|483|[Smallest Good Base](https://leetcode.com/problems/smallest-good-base)| [Python](./python/483%20Smallest%20Good%20Base.py) [Java]() |Hard|| +|507|[Perfect Number](https://leetcode.com/problems/perfect-number)| [Python](./python/507%20Perfect%20Number.py) [Java]() |Easy|| +|517|[Super Washing Machines](https://leetcode.com/problems/super-washing-machines)| [Python](./python/517%20Super%20Washing%20Machines.py) [Java]() |Hard|| +|523|[Continuous Subarray Sum](https://leetcode.com/problems/continuous-subarray-sum)| [Python](./python/523%20Continuous%20Subarray%20Sum.py) [Java]() |Medium|| +|535|[Encode and Decode TinyURL](https://leetcode.com/problems/encode-and-decode-tinyurl)| [Python](./python/535%20Encode%20and%20Decode%20TinyURL.py) [Java]() |Medium|| +|537|[Complex Number Multiplication](https://leetcode.com/problems/complex-number-multiplication)| [Python](./python/537%20Complex%20Number%20Multiplication.py) [Java]() |Medium|| +|553|[Optimal Division](https://leetcode.com/problems/optimal-division)| [Python](./python/553%20Optimal%20Division.py) [Java]() |Medium|| ## Two Pointers | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|3|[Longest Substring Without Repeating Characters](https://leetcode.com/problems/longest-substring-without-repeating-characters)|[Python](./python/003 Longest Substring Without Repeating Characters.py) [Java]()|Medium|| -|11|[Container With Most Water](https://leetcode.com/problems/container-with-most-water)|[Python](./python/011 Container With Most Water.py) [Java]()|Medium|| -|15|[3Sum](https://leetcode.com/problems/3sum)|[Python](./python/015 3Sum.py) [Java]()|Medium|| -|16|[3Sum Closest](https://leetcode.com/problems/3sum-closest)|[Python](./python/016 3Sum Closest.py) [Java]()|Medium|| -|18|[4Sum](https://leetcode.com/problems/4sum)|[Python](./python/018 4Sum.py) [Java]()|Medium|| -|19|[Remove Nth Node From End of List](https://leetcode.com/problems/remove-nth-node-from-end-of-list)|[Python](./python/019 Remove Nth Node From End of List.py) [Java]()|Medium|| -|26|[Remove Duplicates from Sorted Array](https://leetcode.com/problems/remove-duplicates-from-sorted-array)|[Python](./python/026 Remove Duplicates from Sorted Array.py) [Java]()|Easy|| -|27|[Remove Element](https://leetcode.com/problems/remove-element)|[Python](./python/027 Remove Element.py) [Java]()|Easy|| -|28|[Implement strStr()](https://leetcode.com/problems/implement-strstr())|[Python](./python/028 Implement strStr().py) [Java]()|Easy|| -|30|[Substring with Concatenation of All Words](https://leetcode.com/problems/substring-with-concatenation-of-all-words)|[Python](./python/030 Substring with Concatenation of All Words.py) [Java]()|Hard|| -|42|[Trapping Rain Water](https://leetcode.com/problems/trapping-rain-water)|[Python](./python/042 Trapping Rain Water.py) [Java]()|Hard|| -|61|[Rotate List](https://leetcode.com/problems/rotate-list)|[Python](./python/061 Rotate List.py) [Java]()|Medium|| -|75|[Sort Colors](https://leetcode.com/problems/sort-colors)|[Python](./python/075 Sort Colors.py) [Java]()|Medium|| -|76|[Minimum Window Substring](https://leetcode.com/problems/minimum-window-substring)|[Python](./python/076 Minimum Window Substring.py) [Java]()|Hard|| -|80|[Remove Duplicates from Sorted Array II](https://leetcode.com/problems/remove-duplicates-from-sorted-array-ii)|[Python](./python/080 Remove Duplicates from Sorted Array II.py) [Java]()|Medium|| -|86|[Partition List](https://leetcode.com/problems/partition-list)|[Python](./python/086 Partition List.py) [Java]()|Medium|| -|88|[Merge Sorted Array](https://leetcode.com/problems/merge-sorted-array)|[Python](./python/088 Merge Sorted Array.py) [Java]()|Easy|| -|125|[Valid Palindrome](https://leetcode.com/problems/valid-palindrome)|[Python](./python/125 Valid Palindrome.py) [Java]()|Easy|| -|141|[Linked List Cycle](https://leetcode.com/problems/linked-list-cycle)|[Python](./python/141 Linked List Cycle.py) [Java]()|Easy|| -|142|[Linked List Cycle II](https://leetcode.com/problems/linked-list-cycle-ii)|[Python](./python/142 Linked List Cycle II.py) [Java]()|Medium|| -|159|[Longest Substring with At Most Two Distinct Characters](https://leetcode.com/problems/longest-substring-with-at-most-two-distinct-characters)|[Python](./python/159 Longest Substring with At Most Two Distinct Characters.py) [Java]()|Hard|| -|167|[Two Sum II - Input array is sorted](https://leetcode.com/problems/two-sum-ii---input-array-is-sorted)|[Python](./python/167 Two Sum II - Input array is sorted.py) [Java]()|Easy|| -|209|[Minimum Size Subarray Sum](https://leetcode.com/problems/minimum-size-subarray-sum)|[Python](./python/209 Minimum Size Subarray Sum.py) [Java]()|Medium|| -|234|[Palindrome Linked List](https://leetcode.com/problems/palindrome-linked-list)|[Python](./python/234 Palindrome Linked List.py) [Java]()|Easy|| -|259|[3Sum Smaller](https://leetcode.com/problems/3sum-smaller)|[Python](./python/259 3Sum Smaller.py) [Java]()|Medium|| -|283|[Move Zeroes](https://leetcode.com/problems/move-zeroes)|[Python](./python/283 Move Zeroes.py) [Java]()|Easy|| -|287|[Find the Duplicate Number](https://leetcode.com/problems/find-the-duplicate-number)|[Python](./python/287 Find the Duplicate Number.py) [Java]()|Medium|| -|344|[Reverse String](https://leetcode.com/problems/reverse-string)|[Python](./python/344 Reverse String.py) [Java]()|Easy|| -|345|[Reverse Vowels of a String](https://leetcode.com/problems/reverse-vowels-of-a-string)|[Python](./python/345 Reverse Vowels of a String.py) [Java]()|Easy|| -|349|[Intersection of Two Arrays](https://leetcode.com/problems/intersection-of-two-arrays)|[Python](./python/349 Intersection of Two Arrays.py) [Java]()|Easy|| -|350|[Intersection of Two Arrays II](https://leetcode.com/problems/intersection-of-two-arrays-ii)|[Python](./python/350 Intersection of Two Arrays II.py) [Java]()|Easy|| -|360|[Sort Transformed Array](https://leetcode.com/problems/sort-transformed-array)|[Python](./python/360 Sort Transformed Array.py) [Java]()|Medium|| -|487|[Max Consecutive Ones II](https://leetcode.com/problems/max-consecutive-ones-ii)|[Python](./python/487 Max Consecutive Ones II.py) [Java]()|Medium|| -|524|[Longest Word in Dictionary through Deleting](https://leetcode.com/problems/longest-word-in-dictionary-through-deleting)|[Python](./python/524 Longest Word in Dictionary through Deleting.py) [Java]()|Medium|| -|532|[K-diff Pairs in an Array](https://leetcode.com/problems/k-diff-pairs-in-an-array)|[Python](./python/532 K-diff Pairs in an Array.py) [Java]()|Easy|| -|567|[Permutation in String](https://leetcode.com/problems/permutation-in-string)|[Python](./python/567 Permutation in String.py) [Java]()|Medium|| +|3|[Longest Substring Without Repeating Characters](https://leetcode.com/problems/longest-substring-without-repeating-characters)| [Python](./python/003%20Longest%20Substring%20Without%20Repeating%20Characters.py) [Java]() |Medium|| +|11|[Container With Most Water](https://leetcode.com/problems/container-with-most-water)| [Python](./python/011%20Container%20With%20Most%20Water.py) [Java]() |Medium|| +|15|[3Sum](https://leetcode.com/problems/3sum)| [Python](./python/015%203Sum.py) [Java]() |Medium|| +|16|[3Sum Closest](https://leetcode.com/problems/3sum-closest)| [Python](./python/016%203Sum%20Closest.py) [Java]() |Medium|| +|18|[4Sum](https://leetcode.com/problems/4sum)| [Python](./python/018%204Sum.py) [Java]() |Medium|| +|19|[Remove Nth Node From End of List](https://leetcode.com/problems/remove-nth-node-from-end-of-list)| [Python](./python/019%20Remove%20Nth%20Node%20From%20End%20of%20List.py) [Java]() |Medium|| +|26|[Remove Duplicates from Sorted Array](https://leetcode.com/problems/remove-duplicates-from-sorted-array)| [Python](./python/026%20Remove%20Duplicates%20from%20Sorted%20Array.py) [Java]() |Easy|| +|27|[Remove Element](https://leetcode.com/problems/remove-element)| [Python](./python/027%20Remove%20Element.py) [Java]() |Easy|| +|28|[Implement strStr()](https://leetcode.com/problems/implement-strstr())| [Python](./python/028%20Implement%20strStr().py) [Java]() |Easy|| +|30|[Substring with Concatenation of All Words](https://leetcode.com/problems/substring-with-concatenation-of-all-words)| [Python](./python/030%20Substring%20with%20Concatenation%20of%20All%20Words.py) [Java]() |Hard|| +|42|[Trapping Rain Water](https://leetcode.com/problems/trapping-rain-water)| [Python](./python/042%20Trapping%20Rain%20Water.py) [Java]() |Hard|| +|61|[Rotate List](https://leetcode.com/problems/rotate-list)| [Python](./python/061%20Rotate%20List.py) [Java]() |Medium|| +|75|[Sort Colors](https://leetcode.com/problems/sort-colors)| [Python](./python/075%20Sort%20Colors.py) [Java]() |Medium|| +|76|[Minimum Window Substring](https://leetcode.com/problems/minimum-window-substring)| [Python](./python/076%20Minimum%20Window%20Substring.py) [Java]() |Hard|| +|80|[Remove Duplicates from Sorted Array II](https://leetcode.com/problems/remove-duplicates-from-sorted-array-ii)| [Python](./python/080%20Remove%20Duplicates%20from%20Sorted%20Array%20II.py) [Java]() |Medium|| +|86|[Partition List](https://leetcode.com/problems/partition-list)| [Python](./python/086%20Partition%20List.py) [Java]() |Medium|| +|88|[Merge Sorted Array](https://leetcode.com/problems/merge-sorted-array)| [Python](./python/088%20Merge%20Sorted%20Array.py) [Java]() |Easy|| +|125|[Valid Palindrome](https://leetcode.com/problems/valid-palindrome)| [Python](./python/125%20Valid%20Palindrome.py) [Java]() |Easy|| +|141|[Linked List Cycle](https://leetcode.com/problems/linked-list-cycle)| [Python](./python/141%20Linked%20List%20Cycle.py) [Java]() |Easy|| +|142|[Linked List Cycle II](https://leetcode.com/problems/linked-list-cycle-ii)| [Python](./python/142%20Linked%20List%20Cycle%20II.py) [Java]() |Medium|| +|159|[Longest Substring with At Most Two Distinct Characters](https://leetcode.com/problems/longest-substring-with-at-most-two-distinct-characters)| [Python](./python/159%20Longest%20Substring%20with%20At%20Most%20Two%20Distinct%20Characters.py) [Java]() |Hard|| +|167|[Two Sum II - Input array is sorted](https://leetcode.com/problems/two-sum-ii---input-array-is-sorted)| [Python](./python/167%20Two%20Sum%20II%20-%20Input%20array%20is%20sorted.py) [Java]() |Easy|| +|209|[Minimum Size Subarray Sum](https://leetcode.com/problems/minimum-size-subarray-sum)| [Python](./python/209%20Minimum%20Size%20Subarray%20Sum.py) [Java]() |Medium|| +|234|[Palindrome Linked List](https://leetcode.com/problems/palindrome-linked-list)| [Python](./python/234%20Palindrome%20Linked%20List.py) [Java]() |Easy|| +|259|[3Sum Smaller](https://leetcode.com/problems/3sum-smaller)| [Python](./python/259%203Sum%20Smaller.py) [Java]() |Medium|| +|283|[Move Zeroes](https://leetcode.com/problems/move-zeroes)| [Python](./python/283%20Move%20Zeroes.py) [Java]() |Easy|| +|287|[Find the Duplicate Number](https://leetcode.com/problems/find-the-duplicate-number)| [Python](./python/287%20Find%20the%20Duplicate%20Number.py) [Java]() |Medium|| +|344|[Reverse String](https://leetcode.com/problems/reverse-string)| [Python](./python/344%20Reverse%20String.py) [Java]() |Easy|| +|345|[Reverse Vowels of a String](https://leetcode.com/problems/reverse-vowels-of-a-string)| [Python](./python/345%20Reverse%20Vowels%20of%20a%20String.py) [Java]() |Easy|| +|349|[Intersection of Two Arrays](https://leetcode.com/problems/intersection-of-two-arrays)| [Python](./python/349%20Intersection%20of%20Two%20Arrays.py) [Java]() |Easy|| +|350|[Intersection of Two Arrays II](https://leetcode.com/problems/intersection-of-two-arrays-ii)| [Python](./python/350%20Intersection%20of%20Two%20Arrays%20II.py) [Java]() |Easy|| +|360|[Sort Transformed Array](https://leetcode.com/problems/sort-transformed-array)| [Python](./python/360%20Sort%20Transformed%20Array.py) [Java]() |Medium|| +|487|[Max Consecutive Ones II](https://leetcode.com/problems/max-consecutive-ones-ii)| [Python](./python/487%20Max%20Consecutive%20Ones%20II.py) [Java]() |Medium|| +|524|[Longest Word in Dictionary through Deleting](https://leetcode.com/problems/longest-word-in-dictionary-through-deleting)| [Python](./python/524%20Longest%20Word%20in%20Dictionary%20through%20Deleting.py) [Java]() |Medium|| +|532|[K-diff Pairs in an Array](https://leetcode.com/problems/k-diff-pairs-in-an-array)| [Python](./python/532%20K-diff%20Pairs%20in%20an%20Array.py) [Java]() |Easy|| +|567|[Permutation in String](https://leetcode.com/problems/permutation-in-string)| [Python](./python/567%20Permutation%20in%20String.py) [Java]() |Medium|| ## String | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|3|[Longest Substring Without Repeating Characters](https://leetcode.com/problems/longest-substring-without-repeating-characters)|[Python](./python/003 Longest Substring Without Repeating Characters.py) [Java]()|Medium|| -|5|[Longest Palindromic Substring](https://leetcode.com/problems/longest-palindromic-substring)|[Python](./python/005 Longest Palindromic Substring.py) [Java]()|Medium|| -|6|[ZigZag Conversion](https://leetcode.com/problems/zigzag-conversion)|[Python](./python/006 ZigZag Conversion.py) [Java]()|Medium|| -|8|[String to Integer (atoi)](https://leetcode.com/problems/string-to-integer-(atoi))|[Python](./python/008 String to Integer (atoi).py) [Java]()|Medium|| -|10|[Regular Expression Matching](https://leetcode.com/problems/regular-expression-matching)|[Python](./python/010 Regular Expression Matching.py) [Java]()|Hard|| -|12|[Integer to Roman](https://leetcode.com/problems/integer-to-roman)|[Python](./python/012 Integer to Roman.py) [Java]()|Medium|| -|13|[Roman to Integer](https://leetcode.com/problems/roman-to-integer)|[Python](./python/013 Roman to Integer.py) [Java]()|Easy|| -|14|[Longest Common Prefix](https://leetcode.com/problems/longest-common-prefix)|[Python](./python/014 Longest Common Prefix.py) [Java]()|Easy|| -|17|[Letter Combinations of a Phone Number](https://leetcode.com/problems/letter-combinations-of-a-phone-number)|[Python](./python/017 Letter Combinations of a Phone Number.py) [Java]()|Medium|| -|20|[Valid Parentheses](https://leetcode.com/problems/valid-parentheses)|[Python](./python/020 Valid Parentheses.py) [Java]()|Easy|| -|22|[Generate Parentheses](https://leetcode.com/problems/generate-parentheses)|[Python](./python/022 Generate Parentheses.py) [Java]()|Medium|| -|28|[Implement strStr()](https://leetcode.com/problems/implement-strstr())|[Python](./python/028 Implement strStr().py) [Java]()|Easy|| -|30|[Substring with Concatenation of All Words](https://leetcode.com/problems/substring-with-concatenation-of-all-words)|[Python](./python/030 Substring with Concatenation of All Words.py) [Java]()|Hard|| -|32|[Longest Valid Parentheses](https://leetcode.com/problems/longest-valid-parentheses)|[Python](./python/032 Longest Valid Parentheses.py) [Java]()|Hard|| -|38|[Count and Say](https://leetcode.com/problems/count-and-say)|[Python](./python/038 Count and Say.py) [Java]()|Easy|| -|43|[Multiply Strings](https://leetcode.com/problems/multiply-strings)|[Python](./python/043 Multiply Strings.py) [Java]()|Medium|| -|44|[Wildcard Matching](https://leetcode.com/problems/wildcard-matching)|[Python](./python/044 Wildcard Matching.py) [Java]()|Hard|| -|49|[Group Anagrams](https://leetcode.com/problems/group-anagrams)|[Python](./python/049 Group Anagrams.py) [Java]()|Medium|| -|58|[Length of Last Word](https://leetcode.com/problems/length-of-last-word)|[Python](./python/058 Length of Last Word.py) [Java]()|Easy|| -|65|[Valid Number](https://leetcode.com/problems/valid-number)|[Python](./python/065 Valid Number.py) [Java]()|Hard|| -|67|[Add Binary](https://leetcode.com/problems/add-binary)|[Python](./python/067 Add Binary.py) [Java]()|Easy|| -|68|[Text Justification](https://leetcode.com/problems/text-justification)|[Python](./python/068 Text Justification.py) [Java]()|Hard|| -|71|[Simplify Path](https://leetcode.com/problems/simplify-path)|[Python](./python/071 Simplify Path.py) [Java]()|Medium|| -|72|[Edit Distance](https://leetcode.com/problems/edit-distance)|[Python](./python/072 Edit Distance.py) [Java]()|Hard|| -|76|[Minimum Window Substring](https://leetcode.com/problems/minimum-window-substring)|[Python](./python/076 Minimum Window Substring.py) [Java]()|Hard|| -|87|[Scramble String](https://leetcode.com/problems/scramble-string)|[Python](./python/087 Scramble String.py) [Java]()|Hard|| -|91|[Decode Ways](https://leetcode.com/problems/decode-ways)|[Python](./python/091 Decode Ways.py) [Java]()|Medium|| -|93|[Restore IP Addresses](https://leetcode.com/problems/restore-ip-addresses)|[Python](./python/093 Restore IP Addresses.py) [Java]()|Medium|| -|97|[Interleaving String](https://leetcode.com/problems/interleaving-string)|[Python](./python/097 Interleaving String.py) [Java]()|Hard|| -|115|[Distinct Subsequences](https://leetcode.com/problems/distinct-subsequences)|[Python](./python/115 Distinct Subsequences.py) [Java]()|Hard|| -|125|[Valid Palindrome](https://leetcode.com/problems/valid-palindrome)|[Python](./python/125 Valid Palindrome.py) [Java]()|Easy|| -|126|[Word Ladder II](https://leetcode.com/problems/word-ladder-ii)|[Python](./python/126 Word Ladder II.py) [Java]()|Hard|| -|151|[Reverse Words in a String](https://leetcode.com/problems/reverse-words-in-a-string)|[Python](./python/151 Reverse Words in a String.py) [Java]()|Medium|| -|157|[Read N Characters Given Read4](https://leetcode.com/problems/read-n-characters-given-read4)|[Python](./python/157 Read N Characters Given Read4.py) [Java]()|Easy|| -|158|[Read N Characters Given Read4 II - Call multiple times](https://leetcode.com/problems/read-n-characters-given-read4-ii---call-multiple-times)|[Python](./python/158 Read N Characters Given Read4 II - Call multiple times.py) [Java]()|Hard|| -|159|[Longest Substring with At Most Two Distinct Characters](https://leetcode.com/problems/longest-substring-with-at-most-two-distinct-characters)|[Python](./python/159 Longest Substring with At Most Two Distinct Characters.py) [Java]()|Hard|| -|161|[One Edit Distance](https://leetcode.com/problems/one-edit-distance)|[Python](./python/161 One Edit Distance.py) [Java]()|Medium|| -|165|[Compare Version Numbers](https://leetcode.com/problems/compare-version-numbers)|[Python](./python/165 Compare Version Numbers.py) [Java]()|Medium|| -|186|[Reverse Words in a String II](https://leetcode.com/problems/reverse-words-in-a-string-ii)|[Python](./python/186 Reverse Words in a String II.py) [Java]()|Medium|| -|214|[Shortest Palindrome](https://leetcode.com/problems/shortest-palindrome)|[Python](./python/214 Shortest Palindrome.py) [Java]()|Hard|| -|227|[Basic Calculator II](https://leetcode.com/problems/basic-calculator-ii)|[Python](./python/227 Basic Calculator II.py) [Java]()|Medium|| -|249|[Group Shifted Strings](https://leetcode.com/problems/group-shifted-strings)|[Python](./python/249 Group Shifted Strings.py) [Java]()|Medium|| -|271|[Encode and Decode Strings](https://leetcode.com/problems/encode-and-decode-strings)|[Python](./python/271 Encode and Decode Strings.py) [Java]()|Medium|| -|273|[Integer to English Words](https://leetcode.com/problems/integer-to-english-words)|[Python](./python/273 Integer to English Words.py) [Java]()|Hard|| -|293|[Flip Game](https://leetcode.com/problems/flip-game)|[Python](./python/293 Flip Game.py) [Java]()|Easy|| -|336|[Palindrome Pairs](https://leetcode.com/problems/palindrome-pairs)|[Python](./python/336 Palindrome Pairs.py) [Java]()|Hard|| -|340|[Longest Substring with At Most K Distinct Characters](https://leetcode.com/problems/longest-substring-with-at-most-k-distinct-characters)|[Python](./python/340 Longest Substring with At Most K Distinct Characters.py) [Java]()|Hard|| -|344|[Reverse String](https://leetcode.com/problems/reverse-string)|[Python](./python/344 Reverse String.py) [Java]()|Easy|| -|345|[Reverse Vowels of a String](https://leetcode.com/problems/reverse-vowels-of-a-string)|[Python](./python/345 Reverse Vowels of a String.py) [Java]()|Easy|| -|383|[Ransom Note](https://leetcode.com/problems/ransom-note)|[Python](./python/383 Ransom Note.py) [Java]()|Easy|| -|385|[Mini Parser](https://leetcode.com/problems/mini-parser)|[Python](./python/385 Mini Parser.py) [Java]()|Medium|| -|408|[Valid Word Abbreviation](https://leetcode.com/problems/valid-word-abbreviation)|[Python](./python/408 Valid Word Abbreviation.py) [Java]()|Easy|| -|434|[Number of Segments in a String](https://leetcode.com/problems/number-of-segments-in-a-string)|[Python](./python/434 Number of Segments in a String.py) [Java]()|Easy|| -|459|[Repeated Substring Pattern](https://leetcode.com/problems/repeated-substring-pattern)|[Python](./python/459 Repeated Substring Pattern.py) [Java]()|Easy|| -|468|[Validate IP Address](https://leetcode.com/problems/validate-ip-address)|[Python](./python/468 Validate IP Address.py) [Java]()|Medium|| -|520|[Detect Capital](https://leetcode.com/problems/detect-capital)|[Python](./python/520 Detect Capital.py) [Java]()|Easy|| -|521|[Longest Uncommon Subsequence I](https://leetcode.com/problems/longest-uncommon-subsequence-i)|[Python](./python/521 Longest Uncommon Subsequence I.py) [Java]()|Easy|| -|522|[Longest Uncommon Subsequence II](https://leetcode.com/problems/longest-uncommon-subsequence-ii)|[Python](./python/522 Longest Uncommon Subsequence II.py) [Java]()|Medium|| -|527|[Word Abbreviation](https://leetcode.com/problems/word-abbreviation)|[Python](./python/527 Word Abbreviation.py) [Java]()|Hard|| -|536|[Construct Binary Tree from String](https://leetcode.com/problems/construct-binary-tree-from-string)|[Python](./python/536 Construct Binary Tree from String.py) [Java]()|Medium|| -|537|[Complex Number Multiplication](https://leetcode.com/problems/complex-number-multiplication)|[Python](./python/537 Complex Number Multiplication.py) [Java]()|Medium|| -|539|[Minimum Time Difference](https://leetcode.com/problems/minimum-time-difference)|[Python](./python/539 Minimum Time Difference.py) [Java]()|Medium|| -|541|[Reverse String II](https://leetcode.com/problems/reverse-string-ii)|[Python](./python/541 Reverse String II.py) [Java]()|Easy|| -|544|[Output Contest Matches](https://leetcode.com/problems/output-contest-matches)|[Python](./python/544 Output Contest Matches.py) [Java]()|Medium|| -|551|[Student Attendance Record I](https://leetcode.com/problems/student-attendance-record-i)|[Python](./python/551 Student Attendance Record I.py) [Java]()|Easy|| -|553|[Optimal Division](https://leetcode.com/problems/optimal-division)|[Python](./python/553 Optimal Division.py) [Java]()|Medium|| -|555|[Split Concatenated Strings](https://leetcode.com/problems/split-concatenated-strings)|[Python](./python/555 Split Concatenated Strings.py) [Java]()|Medium|| -|556|[Next Greater Element III](https://leetcode.com/problems/next-greater-element-iii)|[Python](./python/556 Next Greater Element III.py) [Java]()|Medium|| -|557|[Reverse Words in a String III](https://leetcode.com/problems/reverse-words-in-a-string-iii)|[Python](./python/557 Reverse Words in a String III.py) [Java]()|Easy|| -|564|[Find the Closest Palindrome](https://leetcode.com/problems/find-the-closest-palindrome)|[Python](./python/564 Find the Closest Palindrome.py) [Java]()|Hard|| +|3|[Longest Substring Without Repeating Characters](https://leetcode.com/problems/longest-substring-without-repeating-characters)| [Python](./python/003%20Longest%20Substring%20Without%20Repeating%20Characters.py) [Java]() |Medium|| +|5|[Longest Palindromic Substring](https://leetcode.com/problems/longest-palindromic-substring)| [Python](./python/005%20Longest%20Palindromic%20Substring.py) [Java]() |Medium|| +|6|[ZigZag Conversion](https://leetcode.com/problems/zigzag-conversion)| [Python](./python/006%20ZigZag%20Conversion.py) [Java]() |Medium|| +|8|[String to Integer (atoi)](https://leetcode.com/problems/string-to-integer-(atoi))| [Python](./python/008%20String%20to%20Integer%20(atoi).py) [Java]() |Medium|| +|10|[Regular Expression Matching](https://leetcode.com/problems/regular-expression-matching)| [Python](./python/010%20Regular%20Expression%20Matching.py) [Java]() |Hard|| +|12|[Integer to Roman](https://leetcode.com/problems/integer-to-roman)| [Python](./python/012%20Integer%20to%20Roman.py) [Java]() |Medium|| +|13|[Roman to Integer](https://leetcode.com/problems/roman-to-integer)| [Python](./python/013%20Roman%20to%20Integer.py) [Java]() |Easy|| +|14|[Longest Common Prefix](https://leetcode.com/problems/longest-common-prefix)| [Python](./python/014%20Longest%20Common%20Prefix.py) [Java]() |Easy|| +|17|[Letter Combinations of a Phone Number](https://leetcode.com/problems/letter-combinations-of-a-phone-number)| [Python](./python/017%20Letter%20Combinations%20of%20a%20Phone%20Number.py) [Java]() |Medium|| +|20|[Valid Parentheses](https://leetcode.com/problems/valid-parentheses)| [Python](./python/020%20Valid%20Parentheses.py) [Java]() |Easy|| +|22|[Generate Parentheses](https://leetcode.com/problems/generate-parentheses)| [Python](./python/022%20Generate%20Parentheses.py) [Java]() |Medium|| +|28|[Implement strStr()](https://leetcode.com/problems/implement-strstr())| [Python](./python/028%20Implement%20strStr().py) [Java]() |Easy|| +|30|[Substring with Concatenation of All Words](https://leetcode.com/problems/substring-with-concatenation-of-all-words)| [Python](./python/030%20Substring%20with%20Concatenation%20of%20All%20Words.py) [Java]() |Hard|| +|32|[Longest Valid Parentheses](https://leetcode.com/problems/longest-valid-parentheses)| [Python](./python/032%20Longest%20Valid%20Parentheses.py) [Java]() |Hard|| +|38|[Count and Say](https://leetcode.com/problems/count-and-say)| [Python](./python/038%20Count%20and%20Say.py) [Java]() |Easy|| +|43|[Multiply Strings](https://leetcode.com/problems/multiply-strings)| [Python](./python/043%20Multiply%20Strings.py) [Java]() |Medium|| +|44|[Wildcard Matching](https://leetcode.com/problems/wildcard-matching)| [Python](./python/044%20Wildcard%20Matching.py) [Java]() |Hard|| +|49|[Group Anagrams](https://leetcode.com/problems/group-anagrams)| [Python](./python/049%20Group%20Anagrams.py) [Java]() |Medium|| +|58|[Length of Last Word](https://leetcode.com/problems/length-of-last-word)| [Python](./python/058%20Length%20of%20Last%20Word.py) [Java]() |Easy|| +|65|[Valid Number](https://leetcode.com/problems/valid-number)| [Python](./python/065%20Valid%20Number.py) [Java]() |Hard|| +|67|[Add Binary](https://leetcode.com/problems/add-binary)| [Python](./python/067%20Add%20Binary.py) [Java]() |Easy|| +|68|[Text Justification](https://leetcode.com/problems/text-justification)| [Python](./python/068%20Text%20Justification.py) [Java]() |Hard|| +|71|[Simplify Path](https://leetcode.com/problems/simplify-path)| [Python](./python/071%20Simplify%20Path.py) [Java]() |Medium|| +|72|[Edit Distance](https://leetcode.com/problems/edit-distance)| [Python](./python/072%20Edit%20Distance.py) [Java]() |Hard|| +|76|[Minimum Window Substring](https://leetcode.com/problems/minimum-window-substring)| [Python](./python/076%20Minimum%20Window%20Substring.py) [Java]() |Hard|| +|87|[Scramble String](https://leetcode.com/problems/scramble-string)| [Python](./python/087%20Scramble%20String.py) [Java]() |Hard|| +|91|[Decode Ways](https://leetcode.com/problems/decode-ways)| [Python](./python/091%20Decode%20Ways.py) [Java]() |Medium|| +|93|[Restore IP Addresses](https://leetcode.com/problems/restore-ip-addresses)| [Python](./python/093%20Restore%20IP%20Addresses.py) [Java]() |Medium|| +|97|[Interleaving String](https://leetcode.com/problems/interleaving-string)| [Python](./python/097%20Interleaving%20String.py) [Java]() |Hard|| +|115|[Distinct Subsequences](https://leetcode.com/problems/distinct-subsequences)| [Python](./python/115%20Distinct%20Subsequences.py) [Java]() |Hard|| +|125|[Valid Palindrome](https://leetcode.com/problems/valid-palindrome)| [Python](./python/125%20Valid%20Palindrome.py) [Java]() |Easy|| +|126|[Word Ladder II](https://leetcode.com/problems/word-ladder-ii)| [Python](./python/126%20Word%20Ladder%20II.py) [Java]() |Hard|| +|151|[Reverse Words in a String](https://leetcode.com/problems/reverse-words-in-a-string)| [Python](./python/151%20Reverse%20Words%20in%20a%20String.py) [Java]() |Medium|| +|157|[Read N Characters Given Read4](https://leetcode.com/problems/read-n-characters-given-read4)| [Python](./python/157%20Read%20N%20Characters%20Given%20Read4.py) [Java]() |Easy|| +|158|[Read N Characters Given Read4 II - Call multiple times](https://leetcode.com/problems/read-n-characters-given-read4-ii---call-multiple-times)| [Python](./python/158%20Read%20N%20Characters%20Given%20Read4%20II%20-%20Call%20multiple%20times.py) [Java]() |Hard|| +|159|[Longest Substring with At Most Two Distinct Characters](https://leetcode.com/problems/longest-substring-with-at-most-two-distinct-characters)| [Python](./python/159%20Longest%20Substring%20with%20At%20Most%20Two%20Distinct%20Characters.py) [Java]() |Hard|| +|161|[One Edit Distance](https://leetcode.com/problems/one-edit-distance)| [Python](./python/161%20One%20Edit%20Distance.py) [Java]() |Medium|| +|165|[Compare Version Numbers](https://leetcode.com/problems/compare-version-numbers)| [Python](./python/165%20Compare%20Version%20Numbers.py) [Java]() |Medium|| +|186|[Reverse Words in a String II](https://leetcode.com/problems/reverse-words-in-a-string-ii)| [Python](./python/186%20Reverse%20Words%20in%20a%20String%20II.py) [Java]() |Medium|| +|214|[Shortest Palindrome](https://leetcode.com/problems/shortest-palindrome)| [Python](./python/214%20Shortest%20Palindrome.py) [Java]() |Hard|| +|227|[Basic Calculator II](https://leetcode.com/problems/basic-calculator-ii)| [Python](./python/227%20Basic%20Calculator%20II.py) [Java]() |Medium|| +|249|[Group Shifted Strings](https://leetcode.com/problems/group-shifted-strings)| [Python](./python/249%20Group%20Shifted%20Strings.py) [Java]() |Medium|| +|271|[Encode and Decode Strings](https://leetcode.com/problems/encode-and-decode-strings)| [Python](./python/271%20Encode%20and%20Decode%20Strings.py) [Java]() |Medium|| +|273|[Integer to English Words](https://leetcode.com/problems/integer-to-english-words)| [Python](./python/273%20Integer%20to%20English%20Words.py) [Java]() |Hard|| +|293|[Flip Game](https://leetcode.com/problems/flip-game)| [Python](./python/293%20Flip%20Game.py) [Java]() |Easy|| +|336|[Palindrome Pairs](https://leetcode.com/problems/palindrome-pairs)| [Python](./python/336%20Palindrome%20Pairs.py) [Java]() |Hard|| +|340|[Longest Substring with At Most K Distinct Characters](https://leetcode.com/problems/longest-substring-with-at-most-k-distinct-characters)| [Python](./python/340%20Longest%20Substring%20with%20At%20Most%20K%20Distinct%20Characters.py) [Java]() |Hard|| +|344|[Reverse String](https://leetcode.com/problems/reverse-string)| [Python](./python/344%20Reverse%20String.py) [Java]() |Easy|| +|345|[Reverse Vowels of a String](https://leetcode.com/problems/reverse-vowels-of-a-string)| [Python](./python/345%20Reverse%20Vowels%20of%20a%20String.py) [Java]() |Easy|| +|383|[Ransom Note](https://leetcode.com/problems/ransom-note)| [Python](./python/383%20Ransom%20Note.py) [Java]() |Easy|| +|385|[Mini Parser](https://leetcode.com/problems/mini-parser)| [Python](./python/385%20Mini%20Parser.py) [Java]() |Medium|| +|408|[Valid Word Abbreviation](https://leetcode.com/problems/valid-word-abbreviation)| [Python](./python/408%20Valid%20Word%20Abbreviation.py) [Java]() |Easy|| +|434|[Number of Segments in a String](https://leetcode.com/problems/number-of-segments-in-a-string)| [Python](./python/434%20Number%20of%20Segments%20in%20a%20String.py) [Java]() |Easy|| +|459|[Repeated Substring Pattern](https://leetcode.com/problems/repeated-substring-pattern)| [Python](./python/459%20Repeated%20Substring%20Pattern.py) [Java]() |Easy|| +|468|[Validate IP Address](https://leetcode.com/problems/validate-ip-address)| [Python](./python/468%20Validate%20IP%20Address.py) [Java]() |Medium|| +|520|[Detect Capital](https://leetcode.com/problems/detect-capital)| [Python](./python/520%20Detect%20Capital.py) [Java]() |Easy|| +|521|[Longest Uncommon Subsequence I](https://leetcode.com/problems/longest-uncommon-subsequence-i)| [Python](./python/521%20Longest%20Uncommon%20Subsequence%20I.py) [Java]() |Easy|| +|522|[Longest Uncommon Subsequence II](https://leetcode.com/problems/longest-uncommon-subsequence-ii)| [Python](./python/522%20Longest%20Uncommon%20Subsequence%20II.py) [Java]() |Medium|| +|527|[Word Abbreviation](https://leetcode.com/problems/word-abbreviation)| [Python](./python/527%20Word%20Abbreviation.py) [Java]() |Hard|| +|536|[Construct Binary Tree from String](https://leetcode.com/problems/construct-binary-tree-from-string)| [Python](./python/536%20Construct%20Binary%20Tree%20from%20String.py) [Java]() |Medium|| +|537|[Complex Number Multiplication](https://leetcode.com/problems/complex-number-multiplication)| [Python](./python/537%20Complex%20Number%20Multiplication.py) [Java]() |Medium|| +|539|[Minimum Time Difference](https://leetcode.com/problems/minimum-time-difference)| [Python](./python/539%20Minimum%20Time%20Difference.py) [Java]() |Medium|| +|541|[Reverse String II](https://leetcode.com/problems/reverse-string-ii)| [Python](./python/541%20Reverse%20String%20II.py) [Java]() |Easy|| +|544|[Output Contest Matches](https://leetcode.com/problems/output-contest-matches)| [Python](./python/544%20Output%20Contest%20Matches.py) [Java]() |Medium|| +|551|[Student Attendance Record I](https://leetcode.com/problems/student-attendance-record-i)| [Python](./python/551%20Student%20Attendance%20Record%20I.py) [Java]() |Easy|| +|553|[Optimal Division](https://leetcode.com/problems/optimal-division)| [Python](./python/553%20Optimal%20Division.py) [Java]() |Medium|| +|555|[Split Concatenated Strings](https://leetcode.com/problems/split-concatenated-strings)| [Python](./python/555%20Split%20Concatenated%20Strings.py) [Java]() |Medium|| +|556|[Next Greater Element III](https://leetcode.com/problems/next-greater-element-iii)| [Python](./python/556%20Next%20Greater%20Element%20III.py) [Java]() |Medium|| +|557|[Reverse Words in a String III](https://leetcode.com/problems/reverse-words-in-a-string-iii)| [Python](./python/557%20Reverse%20Words%20in%20a%20String%20III.py) [Java]() |Easy|| +|564|[Find the Closest Palindrome](https://leetcode.com/problems/find-the-closest-palindrome)| [Python](./python/564%20Find%20the%20Closest%20Palindrome.py) [Java]() |Hard|| ## Binary Search | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|4|[Median of Two Sorted Arrays](https://leetcode.com/problems/median-of-two-sorted-arrays)|[Python](./python/004 Median of Two Sorted Arrays.py) [Java]()|Hard|| -|29|[Divide Two Integers](https://leetcode.com/problems/divide-two-integers)|[Python](./python/029 Divide Two Integers.py) [Java]()|Medium|| -|33|[Search in Rotated Sorted Array](https://leetcode.com/problems/search-in-rotated-sorted-array)|[Python](./python/033 Search in Rotated Sorted Array.py) [Java]()|Medium|| -|34|[Search for a Range](https://leetcode.com/problems/search-for-a-range)|[Python](./python/034 Search for a Range.py) [Java]()|Medium|| -|35|[Search Insert Position](https://leetcode.com/problems/search-insert-position)|[Python](./python/035 Search Insert Position.py) [Java]()|Easy|| -|50|[Pow(x, n)](https://leetcode.com/problems/pow(x,-n))|[Python](./python/050 Pow(x, n).py) [Java]()|Medium|| -|69|[Sqrt(x)](https://leetcode.com/problems/sqrt(x))|[Python](./python/069 Sqrt(x).py) [Java]()|Easy|| -|74|[Search a 2D Matrix](https://leetcode.com/problems/search-a-2d-matrix)|[Python](./python/074 Search a 2D Matrix.py) [Java]()|Medium|| -|81|[Search in Rotated Sorted Array II](https://leetcode.com/problems/search-in-rotated-sorted-array-ii)|[Python](./python/081 Search in Rotated Sorted Array II.py) [Java]()|Medium|| -|153|[Find Minimum in Rotated Sorted Array](https://leetcode.com/problems/find-minimum-in-rotated-sorted-array)|[Python](./python/153 Find Minimum in Rotated Sorted Array.py) [Java]()|Medium|| -|154|[Find Minimum in Rotated Sorted Array II](https://leetcode.com/problems/find-minimum-in-rotated-sorted-array-ii)|[Python](./python/154 Find Minimum in Rotated Sorted Array II.py) [Java]()|Hard|| -|162|[Find Peak Element](https://leetcode.com/problems/find-peak-element)|[Python](./python/162 Find Peak Element.py) [Java]()|Medium|| -|167|[Two Sum II - Input array is sorted](https://leetcode.com/problems/two-sum-ii---input-array-is-sorted)|[Python](./python/167 Two Sum II - Input array is sorted.py) [Java]()|Easy|| -|174|[Dungeon Game](https://leetcode.com/problems/dungeon-game)|[Python](./python/174 Dungeon Game.py) [Java]()|Hard|| -|209|[Minimum Size Subarray Sum](https://leetcode.com/problems/minimum-size-subarray-sum)|[Python](./python/209 Minimum Size Subarray Sum.py) [Java]()|Medium|| -|222|[Count Complete Tree Nodes](https://leetcode.com/problems/count-complete-tree-nodes)|[Python](./python/222 Count Complete Tree Nodes.py) [Java]()|Medium|| -|230|[Kth Smallest Element in a BST](https://leetcode.com/problems/kth-smallest-element-in-a-bst)|[Python](./python/230 Kth Smallest Element in a BST.py) [Java]()|Medium|| -|240|[Search a 2D Matrix II](https://leetcode.com/problems/search-a-2d-matrix-ii)|[Python](./python/240 Search a 2D Matrix II.py) [Java]()|Medium|| -|270|[Closest Binary Search Tree Value](https://leetcode.com/problems/closest-binary-search-tree-value)|[Python](./python/270 Closest Binary Search Tree Value.py) [Java]()|Easy|| -|275|[H-Index II](https://leetcode.com/problems/h-index-ii)|[Python](./python/275 H-Index II.py) [Java]()|Medium|| -|278|[First Bad Version](https://leetcode.com/problems/first-bad-version)|[Python](./python/278 First Bad Version.py) [Java]()|Easy|| -|287|[Find the Duplicate Number](https://leetcode.com/problems/find-the-duplicate-number)|[Python](./python/287 Find the Duplicate Number.py) [Java]()|Medium|| -|300|[Longest Increasing Subsequence](https://leetcode.com/problems/longest-increasing-subsequence)|[Python](./python/300 Longest Increasing Subsequence.py) [Java]()|Medium|| -|302|[Smallest Rectangle Enclosing Black Pixels](https://leetcode.com/problems/smallest-rectangle-enclosing-black-pixels)|[Python](./python/302 Smallest Rectangle Enclosing Black Pixels.py) [Java]()|Hard|| -|349|[Intersection of Two Arrays](https://leetcode.com/problems/intersection-of-two-arrays)|[Python](./python/349 Intersection of Two Arrays.py) [Java]()|Easy|| -|350|[Intersection of Two Arrays II](https://leetcode.com/problems/intersection-of-two-arrays-ii)|[Python](./python/350 Intersection of Two Arrays II.py) [Java]()|Easy|| -|354|[Russian Doll Envelopes](https://leetcode.com/problems/russian-doll-envelopes)|[Python](./python/354 Russian Doll Envelopes.py) [Java]()|Hard|| -|363|[Max Sum of Rectangle No Larger Than K](https://leetcode.com/problems/max-sum-of-rectangle-no-larger-than-k)|[Python](./python/363 Max Sum of Rectangle No Larger Than K.py) [Java]()|Hard|| -|367|[Valid Perfect Square](https://leetcode.com/problems/valid-perfect-square)|[Python](./python/367 Valid Perfect Square.py) [Java]()|Easy|| -|374|[Guess Number Higher or Lower](https://leetcode.com/problems/guess-number-higher-or-lower)|[Python](./python/374 Guess Number Higher or Lower.py) [Java]()|Easy|| -|378|[Kth Smallest Element in a Sorted Matrix](https://leetcode.com/problems/kth-smallest-element-in-a-sorted-matrix)|[Python](./python/378 Kth Smallest Element in a Sorted Matrix.py) [Java]()|Medium|| -|392|[Is Subsequence](https://leetcode.com/problems/is-subsequence)|[Python](./python/392 Is Subsequence.py) [Java]()|Medium|| -|410|[Split Array Largest Sum](https://leetcode.com/problems/split-array-largest-sum)|[Python](./python/410 Split Array Largest Sum.py) [Java]()|Hard|| -|436|[Find Right Interval](https://leetcode.com/problems/find-right-interval)|[Python](./python/436 Find Right Interval.py) [Java]()|Medium|| -|441|[Arranging Coins](https://leetcode.com/problems/arranging-coins)|[Python](./python/441 Arranging Coins.py) [Java]()|Easy|| -|454|[4Sum II](https://leetcode.com/problems/4sum-ii)|[Python](./python/454 4Sum II.py) [Java]()|Medium|| -|475|[Heaters](https://leetcode.com/problems/heaters)|[Python](./python/475 Heaters.py) [Java]()|Easy|| -|483|[Smallest Good Base](https://leetcode.com/problems/smallest-good-base)|[Python](./python/483 Smallest Good Base.py) [Java]()|Hard|| +|4|[Median of Two Sorted Arrays](https://leetcode.com/problems/median-of-two-sorted-arrays)| [Python](./python/004%20Median%20of%20Two%20Sorted%20Arrays.py) [Java]() |Hard|| +|29|[Divide Two Integers](https://leetcode.com/problems/divide-two-integers)| [Python](./python/029%20Divide%20Two%20Integers.py) [Java]() |Medium|| +|33|[Search in Rotated Sorted Array](https://leetcode.com/problems/search-in-rotated-sorted-array)| [Python](./python/033%20Search%20in%20Rotated%20Sorted%20Array.py) [Java]() |Medium|| +|34|[Search for a Range](https://leetcode.com/problems/search-for-a-range)| [Python](./python/034%20Search%20for%20a%20Range.py) [Java]() |Medium|| +|35|[Search Insert Position](https://leetcode.com/problems/search-insert-position)| [Python](./python/035%20Search%20Insert%20Position.py) [Java]() |Easy|| +|50|[Pow(x, n)](https://leetcode.com/problems/pow(x,-n))| [Python](./python/050%20Pow(x,%20n).py) [Java]() |Medium|| +|69|[Sqrt(x)](https://leetcode.com/problems/sqrt(x))| [Python](./python/069%20Sqrt(x).py) [Java]() |Easy|| +|74|[Search a 2D Matrix](https://leetcode.com/problems/search-a-2d-matrix)| [Python](./python/074%20Search%20a%202D%20Matrix.py) [Java]() |Medium|| +|81|[Search in Rotated Sorted Array II](https://leetcode.com/problems/search-in-rotated-sorted-array-ii)| [Python](./python/081%20Search%20in%20Rotated%20Sorted%20Array%20II.py) [Java]() |Medium|| +|153|[Find Minimum in Rotated Sorted Array](https://leetcode.com/problems/find-minimum-in-rotated-sorted-array)| [Python](./python/153%20Find%20Minimum%20in%20Rotated%20Sorted%20Array.py) [Java]() |Medium|| +|154|[Find Minimum in Rotated Sorted Array II](https://leetcode.com/problems/find-minimum-in-rotated-sorted-array-ii)| [Python](./python/154%20Find%20Minimum%20in%20Rotated%20Sorted%20Array%20II.py) [Java]() |Hard|| +|162|[Find Peak Element](https://leetcode.com/problems/find-peak-element)| [Python](./python/162%20Find%20Peak%20Element.py) [Java]() |Medium|| +|167|[Two Sum II - Input array is sorted](https://leetcode.com/problems/two-sum-ii---input-array-is-sorted)| [Python](./python/167%20Two%20Sum%20II%20-%20Input%20array%20is%20sorted.py) [Java]() |Easy|| +|174|[Dungeon Game](https://leetcode.com/problems/dungeon-game)| [Python](./python/174%20Dungeon%20Game.py) [Java]() |Hard|| +|209|[Minimum Size Subarray Sum](https://leetcode.com/problems/minimum-size-subarray-sum)| [Python](./python/209%20Minimum%20Size%20Subarray%20Sum.py) [Java]() |Medium|| +|222|[Count Complete Tree Nodes](https://leetcode.com/problems/count-complete-tree-nodes)| [Python](./python/222%20Count%20Complete%20Tree%20Nodes.py) [Java]() |Medium|| +|230|[Kth Smallest Element in a BST](https://leetcode.com/problems/kth-smallest-element-in-a-bst)| [Python](./python/230%20Kth%20Smallest%20Element%20in%20a%20BST.py) [Java]() |Medium|| +|240|[Search a 2D Matrix II](https://leetcode.com/problems/search-a-2d-matrix-ii)| [Python](./python/240%20Search%20a%202D%20Matrix%20II.py) [Java]() |Medium|| +|270|[Closest Binary Search Tree Value](https://leetcode.com/problems/closest-binary-search-tree-value)| [Python](./python/270%20Closest%20Binary%20Search%20Tree%20Value.py) [Java]() |Easy|| +|275|[H-Index II](https://leetcode.com/problems/h-index-ii)| [Python](./python/275%20H-Index%20II.py) [Java]() |Medium|| +|278|[First Bad Version](https://leetcode.com/problems/first-bad-version)| [Python](./python/278%20First%20Bad%20Version.py) [Java]() |Easy|| +|287|[Find the Duplicate Number](https://leetcode.com/problems/find-the-duplicate-number)| [Python](./python/287%20Find%20the%20Duplicate%20Number.py) [Java]() |Medium|| +|300|[Longest Increasing Subsequence](https://leetcode.com/problems/longest-increasing-subsequence)| [Python](./python/300%20Longest%20Increasing%20Subsequence.py) [Java]() |Medium|| +|302|[Smallest Rectangle Enclosing Black Pixels](https://leetcode.com/problems/smallest-rectangle-enclosing-black-pixels)| [Python](./python/302%20Smallest%20Rectangle%20Enclosing%20Black%20Pixels.py) [Java]() |Hard|| +|349|[Intersection of Two Arrays](https://leetcode.com/problems/intersection-of-two-arrays)| [Python](./python/349%20Intersection%20of%20Two%20Arrays.py) [Java]() |Easy|| +|350|[Intersection of Two Arrays II](https://leetcode.com/problems/intersection-of-two-arrays-ii)| [Python](./python/350%20Intersection%20of%20Two%20Arrays%20II.py) [Java]() |Easy|| +|354|[Russian Doll Envelopes](https://leetcode.com/problems/russian-doll-envelopes)| [Python](./python/354%20Russian%20Doll%20Envelopes.py) [Java]() |Hard|| +|363|[Max Sum of Rectangle No Larger Than K](https://leetcode.com/problems/max-sum-of-rectangle-no-larger-than-k)| [Python](./python/363%20Max%20Sum%20of%20Rectangle%20No%20Larger%20Than%20K.py) [Java]() |Hard|| +|367|[Valid Perfect Square](https://leetcode.com/problems/valid-perfect-square)| [Python](./python/367%20Valid%20Perfect%20Square.py) [Java]() |Easy|| +|374|[Guess Number Higher or Lower](https://leetcode.com/problems/guess-number-higher-or-lower)| [Python](./python/374%20Guess%20Number%20Higher%20or%20Lower.py) [Java]() |Easy|| +|378|[Kth Smallest Element in a Sorted Matrix](https://leetcode.com/problems/kth-smallest-element-in-a-sorted-matrix)| [Python](./python/378%20Kth%20Smallest%20Element%20in%20a%20Sorted%20Matrix.py) [Java]() |Medium|| +|392|[Is Subsequence](https://leetcode.com/problems/is-subsequence)| [Python](./python/392%20Is%20Subsequence.py) [Java]() |Medium|| +|410|[Split Array Largest Sum](https://leetcode.com/problems/split-array-largest-sum)| [Python](./python/410%20Split%20Array%20Largest%20Sum.py) [Java]() |Hard|| +|436|[Find Right Interval](https://leetcode.com/problems/find-right-interval)| [Python](./python/436%20Find%20Right%20Interval.py) [Java]() |Medium|| +|441|[Arranging Coins](https://leetcode.com/problems/arranging-coins)| [Python](./python/441%20Arranging%20Coins.py) [Java]() |Easy|| +|454|[4Sum II](https://leetcode.com/problems/4sum-ii)| [Python](./python/454%204Sum%20II.py) [Java]() |Medium|| +|475|[Heaters](https://leetcode.com/problems/heaters)| [Python](./python/475%20Heaters.py) [Java]() |Easy|| +|483|[Smallest Good Base](https://leetcode.com/problems/smallest-good-base)| [Python](./python/483%20Smallest%20Good%20Base.py) [Java]() |Hard|| ## Divide and Conquer | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|4|[Median of Two Sorted Arrays](https://leetcode.com/problems/median-of-two-sorted-arrays)|[Python](./python/004 Median of Two Sorted Arrays.py) [Java]()|Hard|| -|23|[Merge k Sorted Lists](https://leetcode.com/problems/merge-k-sorted-lists)|[Python](./python/023 Merge k Sorted Lists.py) [Java]()|Hard|| -|53|[Maximum Subarray](https://leetcode.com/problems/maximum-subarray)|[Python](./python/053 Maximum Subarray.py) [Java]()|Easy|| -|169|[Majority Element](https://leetcode.com/problems/majority-element)|[Python](./python/169 Majority Element.py) [Java]()|Easy|| -|215|[Kth Largest Element in an Array](https://leetcode.com/problems/kth-largest-element-in-an-array)|[Python](./python/215 Kth Largest Element in an Array.py) [Java]()|Medium|| -|218|[The Skyline Problem](https://leetcode.com/problems/the-skyline-problem)|[Python](./python/218 The Skyline Problem.py) [Java]()|Hard|| -|240|[Search a 2D Matrix II](https://leetcode.com/problems/search-a-2d-matrix-ii)|[Python](./python/240 Search a 2D Matrix II.py) [Java]()|Medium|| -|241|[Different Ways to Add Parentheses](https://leetcode.com/problems/different-ways-to-add-parentheses)|[Python](./python/241 Different Ways to Add Parentheses.py) [Java]()|Medium|| -|282|[Expression Add Operators](https://leetcode.com/problems/expression-add-operators)|[Python](./python/282 Expression Add Operators.py) [Java]()|Hard|| -|312|[Burst Balloons](https://leetcode.com/problems/burst-balloons)|[Python](./python/312 Burst Balloons.py) [Java]()|Hard|| -|315|[Count of Smaller Numbers After Self](https://leetcode.com/problems/count-of-smaller-numbers-after-self)|[Python](./python/315 Count of Smaller Numbers After Self.py) [Java]()|Hard|| -|327|[Count of Range Sum](https://leetcode.com/problems/count-of-range-sum)|[Python](./python/327 Count of Range Sum.py) [Java]()|Hard|| -|493|[Reverse Pairs](https://leetcode.com/problems/reverse-pairs)|[Python](./python/493 Reverse Pairs.py) [Java]()|Hard|| -|514|[Freedom Trail](https://leetcode.com/problems/freedom-trail)|[Python](./python/514 Freedom Trail.py) [Java]()|Hard|| +|4|[Median of Two Sorted Arrays](https://leetcode.com/problems/median-of-two-sorted-arrays)| [Python](./python/004%20Median%20of%20Two%20Sorted%20Arrays.py) [Java]() |Hard|| +|23|[Merge k Sorted Lists](https://leetcode.com/problems/merge-k-sorted-lists)| [Python](./python/023%20Merge%20k%20Sorted%20Lists.py) [Java]() |Hard|| +|53|[Maximum Subarray](https://leetcode.com/problems/maximum-subarray)| [Python](./python/053%20Maximum%20Subarray.py) [Java]() |Easy|| +|169|[Majority Element](https://leetcode.com/problems/majority-element)| [Python](./python/169%20Majority%20Element.py) [Java]() |Easy|| +|215|[Kth Largest Element in an Array](https://leetcode.com/problems/kth-largest-element-in-an-array)| [Python](./python/215%20Kth%20Largest%20Element%20in%20an%20Array.py) [Java]() |Medium|| +|218|[The Skyline Problem](https://leetcode.com/problems/the-skyline-problem)| [Python](./python/218%20The%20Skyline%20Problem.py) [Java]() |Hard|| +|240|[Search a 2D Matrix II](https://leetcode.com/problems/search-a-2d-matrix-ii)| [Python](./python/240%20Search%20a%202D%20Matrix%20II.py) [Java]() |Medium|| +|241|[Different Ways to Add Parentheses](https://leetcode.com/problems/different-ways-to-add-parentheses)| [Python](./python/241%20Different%20Ways%20to%20Add%20Parentheses.py) [Java]() |Medium|| +|282|[Expression Add Operators](https://leetcode.com/problems/expression-add-operators)| [Python](./python/282%20Expression%20Add%20Operators.py) [Java]() |Hard|| +|312|[Burst Balloons](https://leetcode.com/problems/burst-balloons)| [Python](./python/312%20Burst%20Balloons.py) [Java]() |Hard|| +|315|[Count of Smaller Numbers After Self](https://leetcode.com/problems/count-of-smaller-numbers-after-self)| [Python](./python/315%20Count%20of%20Smaller%20Numbers%20After%20Self.py) [Java]() |Hard|| +|327|[Count of Range Sum](https://leetcode.com/problems/count-of-range-sum)| [Python](./python/327%20Count%20of%20Range%20Sum.py) [Java]() |Hard|| +|493|[Reverse Pairs](https://leetcode.com/problems/reverse-pairs)| [Python](./python/493%20Reverse%20Pairs.py) [Java]() |Hard|| +|514|[Freedom Trail](https://leetcode.com/problems/freedom-trail)| [Python](./python/514%20Freedom%20Trail.py) [Java]() |Hard|| ## Dynamic Programming | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|10|[Regular Expression Matching](https://leetcode.com/problems/regular-expression-matching)|[Python](./python/010 Regular Expression Matching.py) [Java]()|Hard|| -|32|[Longest Valid Parentheses](https://leetcode.com/problems/longest-valid-parentheses)|[Python](./python/032 Longest Valid Parentheses.py) [Java]()|Hard|| -|44|[Wildcard Matching](https://leetcode.com/problems/wildcard-matching)|[Python](./python/044 Wildcard Matching.py) [Java]()|Hard|| -|53|[Maximum Subarray](https://leetcode.com/problems/maximum-subarray)|[Python](./python/053 Maximum Subarray.py) [Java]()|Easy|| -|62|[Unique Paths](https://leetcode.com/problems/unique-paths)|[Python](./python/062 Unique Paths.py) [Java]()|Medium|| -|63|[Unique Paths II](https://leetcode.com/problems/unique-paths-ii)|[Python](./python/063 Unique Paths II.py) [Java]()|Medium|| -|64|[Minimum Path Sum](https://leetcode.com/problems/minimum-path-sum)|[Python](./python/064 Minimum Path Sum.py) [Java]()|Medium|| -|70|[Climbing Stairs](https://leetcode.com/problems/climbing-stairs)|[Python](./python/070 Climbing Stairs.py) [Java]()|Easy|| -|72|[Edit Distance](https://leetcode.com/problems/edit-distance)|[Python](./python/072 Edit Distance.py) [Java]()|Hard|| -|85|[Maximal Rectangle](https://leetcode.com/problems/maximal-rectangle)|[Python](./python/085 Maximal Rectangle.py) [Java]()|Hard|| -|87|[Scramble String](https://leetcode.com/problems/scramble-string)|[Python](./python/087 Scramble String.py) [Java]()|Hard|| -|91|[Decode Ways](https://leetcode.com/problems/decode-ways)|[Python](./python/091 Decode Ways.py) [Java]()|Medium|| -|95|[Unique Binary Search Trees II](https://leetcode.com/problems/unique-binary-search-trees-ii)|[Python](./python/095 Unique Binary Search Trees II.py) [Java]()|Medium|| -|96|[Unique Binary Search Trees](https://leetcode.com/problems/unique-binary-search-trees)|[Python](./python/096 Unique Binary Search Trees.py) [Java]()|Medium|| -|97|[Interleaving String](https://leetcode.com/problems/interleaving-string)|[Python](./python/097 Interleaving String.py) [Java]()|Hard|| -|115|[Distinct Subsequences](https://leetcode.com/problems/distinct-subsequences)|[Python](./python/115 Distinct Subsequences.py) [Java]()|Hard|| -|120|[Triangle](https://leetcode.com/problems/triangle)|[Python](./python/120 Triangle.py) [Java]()|Medium|| -|121|[Best Time to Buy and Sell Stock](https://leetcode.com/problems/best-time-to-buy-and-sell-stock)|[Python](./python/121 Best Time to Buy and Sell Stock.py) [Java]()|Easy|| -|123|[Best Time to Buy and Sell Stock III](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iii)|[Python](./python/123 Best Time to Buy and Sell Stock III.py) [Java]()|Hard|| -|132|[Palindrome Partitioning II](https://leetcode.com/problems/palindrome-partitioning-ii)|[Python](./python/132 Palindrome Partitioning II.py) [Java]()|Hard|| -|139|[Word Break](https://leetcode.com/problems/word-break)|[Python](./python/139 Word Break.py) [Java]()|Medium|| -|140|[Word Break II](https://leetcode.com/problems/word-break-ii)|[Python](./python/140 Word Break II.py) [Java]()|Hard|| -|152|[Maximum Product Subarray](https://leetcode.com/problems/maximum-product-subarray)|[Python](./python/152 Maximum Product Subarray.py) [Java]()|Medium|| -|174|[Dungeon Game](https://leetcode.com/problems/dungeon-game)|[Python](./python/174 Dungeon Game.py) [Java]()|Hard|| -|188|[Best Time to Buy and Sell Stock IV](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iv)|[Python](./python/188 Best Time to Buy and Sell Stock IV.py) [Java]()|Hard|| -|198|[House Robber](https://leetcode.com/problems/house-robber)|[Python](./python/198 House Robber.py) [Java]()|Easy|| -|213|[House Robber II](https://leetcode.com/problems/house-robber-ii)|[Python](./python/213 House Robber II.py) [Java]()|Medium|| -|221|[Maximal Square](https://leetcode.com/problems/maximal-square)|[Python](./python/221 Maximal Square.py) [Java]()|Medium|| -|256|[Paint House](https://leetcode.com/problems/paint-house)|[Python](./python/256 Paint House.py) [Java]()|Easy|| -|264|[Ugly Number II](https://leetcode.com/problems/ugly-number-ii)|[Python](./python/264 Ugly Number II.py) [Java]()|Medium|| -|265|[Paint House II](https://leetcode.com/problems/paint-house-ii)|[Python](./python/265 Paint House II.py) [Java]()|Hard|| -|276|[Paint Fence](https://leetcode.com/problems/paint-fence)|[Python](./python/276 Paint Fence.py) [Java]()|Easy|| -|279|[Perfect Squares](https://leetcode.com/problems/perfect-squares)|[Python](./python/279 Perfect Squares.py) [Java]()|Medium|| -|300|[Longest Increasing Subsequence](https://leetcode.com/problems/longest-increasing-subsequence)|[Python](./python/300 Longest Increasing Subsequence.py) [Java]()|Medium|| -|303|[Range Sum Query - Immutable](https://leetcode.com/problems/range-sum-query---immutable)|[Python](./python/303 Range Sum Query - Immutable.py) [Java]()|Easy|| -|304|[Range Sum Query 2D - Immutable](https://leetcode.com/problems/range-sum-query-2d---immutable)|[Python](./python/304 Range Sum Query 2D - Immutable.py) [Java]()|Medium|| -|309|[Best Time to Buy and Sell Stock with Cooldown](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-cooldown)|[Python](./python/309 Best Time to Buy and Sell Stock with Cooldown.py) [Java]()|Medium|| -|312|[Burst Balloons](https://leetcode.com/problems/burst-balloons)|[Python](./python/312 Burst Balloons.py) [Java]()|Hard|| -|321|[Create Maximum Number](https://leetcode.com/problems/create-maximum-number)|[Python](./python/321 Create Maximum Number.py) [Java]()|Hard|| -|322|[Coin Change](https://leetcode.com/problems/coin-change)|[Python](./python/322 Coin Change.py) [Java]()|Medium|| -|338|[Counting Bits](https://leetcode.com/problems/counting-bits)|[Python](./python/338 Counting Bits.py) [Java]()|Medium|| -|343|[Integer Break](https://leetcode.com/problems/integer-break)|[Python](./python/343 Integer Break.py) [Java]()|Medium|| -|351|[Android Unlock Patterns](https://leetcode.com/problems/android-unlock-patterns)|[Python](./python/351 Android Unlock Patterns.py) [Java]()|Medium|| -|354|[Russian Doll Envelopes](https://leetcode.com/problems/russian-doll-envelopes)|[Python](./python/354 Russian Doll Envelopes.py) [Java]()|Hard|| -|357|[Count Numbers with Unique Digits](https://leetcode.com/problems/count-numbers-with-unique-digits)|[Python](./python/357 Count Numbers with Unique Digits.py) [Java]()|Medium|| -|361|[Bomb Enemy](https://leetcode.com/problems/bomb-enemy)|[Python](./python/361 Bomb Enemy.py) [Java]()|Medium|| -|363|[Max Sum of Rectangle No Larger Than K](https://leetcode.com/problems/max-sum-of-rectangle-no-larger-than-k)|[Python](./python/363 Max Sum of Rectangle No Larger Than K.py) [Java]()|Hard|| -|368|[Largest Divisible Subset](https://leetcode.com/problems/largest-divisible-subset)|[Python](./python/368 Largest Divisible Subset.py) [Java]()|Medium|| -|375|[Guess Number Higher or Lower II](https://leetcode.com/problems/guess-number-higher-or-lower-ii)|[Python](./python/375 Guess Number Higher or Lower II.py) [Java]()|Medium|| -|376|[Wiggle Subsequence](https://leetcode.com/problems/wiggle-subsequence)|[Python](./python/376 Wiggle Subsequence.py) [Java]()|Medium|| -|377|[Combination Sum IV](https://leetcode.com/problems/combination-sum-iv)|[Python](./python/377 Combination Sum IV.py) [Java]()|Medium|| -|392|[Is Subsequence](https://leetcode.com/problems/is-subsequence)|[Python](./python/392 Is Subsequence.py) [Java]()|Medium|| -|403|[Frog Jump](https://leetcode.com/problems/frog-jump)|[Python](./python/403 Frog Jump.py) [Java]()|Hard|| -|410|[Split Array Largest Sum](https://leetcode.com/problems/split-array-largest-sum)|[Python](./python/410 Split Array Largest Sum.py) [Java]()|Hard|| -|413|[Arithmetic Slices](https://leetcode.com/problems/arithmetic-slices)|[Python](./python/413 Arithmetic Slices.py) [Java]()|Medium|| -|416|[Partition Equal Subset Sum](https://leetcode.com/problems/partition-equal-subset-sum)|[Python](./python/416 Partition Equal Subset Sum.py) [Java]()|Medium|| -|418|[Sentence Screen Fitting](https://leetcode.com/problems/sentence-screen-fitting)|[Python](./python/418 Sentence Screen Fitting.py) [Java]()|Medium|| -|446|[Arithmetic Slices II - Subsequence](https://leetcode.com/problems/arithmetic-slices-ii---subsequence)|[Python](./python/446 Arithmetic Slices II - Subsequence.py) [Java]()|Hard|| -|464|[Can I Win](https://leetcode.com/problems/can-i-win)|[Python](./python/464 Can I Win.py) [Java]()|Medium|| -|466|[Count The Repetitions](https://leetcode.com/problems/count-the-repetitions)|[Python](./python/466 Count The Repetitions.py) [Java]()|Hard|| -|467|[Unique Substrings in Wraparound String](https://leetcode.com/problems/unique-substrings-in-wraparound-string)|[Python](./python/467 Unique Substrings in Wraparound String.py) [Java]()|Medium|| -|471|[Encode String with Shortest Length](https://leetcode.com/problems/encode-string-with-shortest-length)|[Python](./python/471 Encode String with Shortest Length.py) [Java]()|Hard|| -|472|[Concatenated Words](https://leetcode.com/problems/concatenated-words)|[Python](./python/472 Concatenated Words.py) [Java]()|Hard|| -|474|[Ones and Zeroes](https://leetcode.com/problems/ones-and-zeroes)|[Python](./python/474 Ones and Zeroes.py) [Java]()|Medium|| -|486|[Predict the Winner](https://leetcode.com/problems/predict-the-winner)|[Python](./python/486 Predict the Winner.py) [Java]()|Medium|| -|494|[Target Sum](https://leetcode.com/problems/target-sum)|[Python](./python/494 Target Sum.py) [Java]()|Medium|| -|514|[Freedom Trail](https://leetcode.com/problems/freedom-trail)|[Python](./python/514 Freedom Trail.py) [Java]()|Hard|| -|516|[Longest Palindromic Subsequence](https://leetcode.com/problems/longest-palindromic-subsequence)|[Python](./python/516 Longest Palindromic Subsequence.py) [Java]()|Medium|| -|517|[Super Washing Machines](https://leetcode.com/problems/super-washing-machines)|[Python](./python/517 Super Washing Machines.py) [Java]()|Hard|| -|523|[Continuous Subarray Sum](https://leetcode.com/problems/continuous-subarray-sum)|[Python](./python/523 Continuous Subarray Sum.py) [Java]()|Medium|| -|546|[Remove Boxes](https://leetcode.com/problems/remove-boxes)|[Python](./python/546 Remove Boxes.py) [Java]()|Hard|| -|552|[Student Attendance Record II](https://leetcode.com/problems/student-attendance-record-ii)|[Python](./python/552 Student Attendance Record II.py) [Java]()|Hard|| -|568|[Maximum Vacation Days](https://leetcode.com/problems/maximum-vacation-days)|[Python](./python/568 Maximum Vacation Days.py) [Java]()|Hard|| +|10|[Regular Expression Matching](https://leetcode.com/problems/regular-expression-matching)| [Python](./python/010%20Regular%20Expression%20Matching.py) [Java]() |Hard|| +|32|[Longest Valid Parentheses](https://leetcode.com/problems/longest-valid-parentheses)| [Python](./python/032%20Longest%20Valid%20Parentheses.py) [Java]() |Hard|| +|44|[Wildcard Matching](https://leetcode.com/problems/wildcard-matching)| [Python](./python/044%20Wildcard%20Matching.py) [Java]() |Hard|| +|53|[Maximum Subarray](https://leetcode.com/problems/maximum-subarray)| [Python](./python/053%20Maximum%20Subarray.py) [Java]() |Easy|| +|62|[Unique Paths](https://leetcode.com/problems/unique-paths)| [Python](./python/062%20Unique%20Paths.py) [Java]() |Medium|| +|63|[Unique Paths II](https://leetcode.com/problems/unique-paths-ii)| [Python](./python/063%20Unique%20Paths%20II.py) [Java]() |Medium|| +|64|[Minimum Path Sum](https://leetcode.com/problems/minimum-path-sum)| [Python](./python/064%20Minimum%20Path%20Sum.py) [Java]() |Medium|| +|70|[Climbing Stairs](https://leetcode.com/problems/climbing-stairs)| [Python](./python/070%20Climbing%20Stairs.py) [Java]() |Easy|| +|72|[Edit Distance](https://leetcode.com/problems/edit-distance)| [Python](./python/072%20Edit%20Distance.py) [Java]() |Hard|| +|85|[Maximal Rectangle](https://leetcode.com/problems/maximal-rectangle)| [Python](./python/085%20Maximal%20Rectangle.py) [Java]() |Hard|| +|87|[Scramble String](https://leetcode.com/problems/scramble-string)| [Python](./python/087%20Scramble%20String.py) [Java]() |Hard|| +|91|[Decode Ways](https://leetcode.com/problems/decode-ways)| [Python](./python/091%20Decode%20Ways.py) [Java]() |Medium|| +|95|[Unique Binary Search Trees II](https://leetcode.com/problems/unique-binary-search-trees-ii)| [Python](./python/095%20Unique%20Binary%20Search%20Trees%20II.py) [Java]() |Medium|| +|96|[Unique Binary Search Trees](https://leetcode.com/problems/unique-binary-search-trees)| [Python](./python/096%20Unique%20Binary%20Search%20Trees.py) [Java]() |Medium|| +|97|[Interleaving String](https://leetcode.com/problems/interleaving-string)| [Python](./python/097%20Interleaving%20String.py) [Java]() |Hard|| +|115|[Distinct Subsequences](https://leetcode.com/problems/distinct-subsequences)| [Python](./python/115%20Distinct%20Subsequences.py) [Java]() |Hard|| +|120|[Triangle](https://leetcode.com/problems/triangle)| [Python](./python/120%20Triangle.py) [Java]() |Medium|| +|121|[Best Time to Buy and Sell Stock](https://leetcode.com/problems/best-time-to-buy-and-sell-stock)| [Python](./python/121%20Best%20Time%20to%20Buy%20and%20Sell%20Stock.py) [Java]() |Easy|| +|123|[Best Time to Buy and Sell Stock III](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iii)| [Python](./python/123%20Best%20Time%20to%20Buy%20and%20Sell%20Stock%20III.py) [Java]() |Hard|| +|132|[Palindrome Partitioning II](https://leetcode.com/problems/palindrome-partitioning-ii)| [Python](./python/132%20Palindrome%20Partitioning%20II.py) [Java]() |Hard|| +|139|[Word Break](https://leetcode.com/problems/word-break)| [Python](./python/139%20Word%20Break.py) [Java]() |Medium|| +|140|[Word Break II](https://leetcode.com/problems/word-break-ii)| [Python](./python/140%20Word%20Break%20II.py) [Java]() |Hard|| +|152|[Maximum Product Subarray](https://leetcode.com/problems/maximum-product-subarray)| [Python](./python/152%20Maximum%20Product%20Subarray.py) [Java]() |Medium|| +|174|[Dungeon Game](https://leetcode.com/problems/dungeon-game)| [Python](./python/174%20Dungeon%20Game.py) [Java]() |Hard|| +|188|[Best Time to Buy and Sell Stock IV](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iv)| [Python](./python/188%20Best%20Time%20to%20Buy%20and%20Sell%20Stock%20IV.py) [Java]() |Hard|| +|198|[House Robber](https://leetcode.com/problems/house-robber)| [Python](./python/198%20House%20Robber.py) [Java]() |Easy|| +|213|[House Robber II](https://leetcode.com/problems/house-robber-ii)| [Python](./python/213%20House%20Robber%20II.py) [Java]() |Medium|| +|221|[Maximal Square](https://leetcode.com/problems/maximal-square)| [Python](./python/221%20Maximal%20Square.py) [Java]() |Medium|| +|256|[Paint House](https://leetcode.com/problems/paint-house)| [Python](./python/256%20Paint%20House.py) [Java]() |Easy|| +|264|[Ugly Number II](https://leetcode.com/problems/ugly-number-ii)| [Python](./python/264%20Ugly%20Number%20II.py) [Java]() |Medium|| +|265|[Paint House II](https://leetcode.com/problems/paint-house-ii)| [Python](./python/265%20Paint%20House%20II.py) [Java]() |Hard|| +|276|[Paint Fence](https://leetcode.com/problems/paint-fence)| [Python](./python/276%20Paint%20Fence.py) [Java]() |Easy|| +|279|[Perfect Squares](https://leetcode.com/problems/perfect-squares)| [Python](./python/279%20Perfect%20Squares.py) [Java]() |Medium|| +|300|[Longest Increasing Subsequence](https://leetcode.com/problems/longest-increasing-subsequence)| [Python](./python/300%20Longest%20Increasing%20Subsequence.py) [Java]() |Medium|| +|303|[Range Sum Query - Immutable](https://leetcode.com/problems/range-sum-query---immutable)| [Python](./python/303%20Range%20Sum%20Query%20-%20Immutable.py) [Java]() |Easy|| +|304|[Range Sum Query 2D - Immutable](https://leetcode.com/problems/range-sum-query-2d---immutable)| [Python](./python/304%20Range%20Sum%20Query%202D%20-%20Immutable.py) [Java]() |Medium|| +|309|[Best Time to Buy and Sell Stock with Cooldown](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-cooldown)| [Python](./python/309%20Best%20Time%20to%20Buy%20and%20Sell%20Stock%20with%20Cooldown.py) [Java]() |Medium|| +|312|[Burst Balloons](https://leetcode.com/problems/burst-balloons)| [Python](./python/312%20Burst%20Balloons.py) [Java]() |Hard|| +|321|[Create Maximum Number](https://leetcode.com/problems/create-maximum-number)| [Python](./python/321%20Create%20Maximum%20Number.py) [Java]() |Hard|| +|322|[Coin Change](https://leetcode.com/problems/coin-change)| [Python](./python/322%20Coin%20Change.py) [Java]() |Medium|| +|338|[Counting Bits](https://leetcode.com/problems/counting-bits)| [Python](./python/338%20Counting%20Bits.py) [Java]() |Medium|| +|343|[Integer Break](https://leetcode.com/problems/integer-break)| [Python](./python/343%20Integer%20Break.py) [Java]() |Medium|| +|351|[Android Unlock Patterns](https://leetcode.com/problems/android-unlock-patterns)| [Python](./python/351%20Android%20Unlock%20Patterns.py) [Java]() |Medium|| +|354|[Russian Doll Envelopes](https://leetcode.com/problems/russian-doll-envelopes)| [Python](./python/354%20Russian%20Doll%20Envelopes.py) [Java]() |Hard|| +|357|[Count Numbers with Unique Digits](https://leetcode.com/problems/count-numbers-with-unique-digits)| [Python](./python/357%20Count%20Numbers%20with%20Unique%20Digits.py) [Java]() |Medium|| +|361|[Bomb Enemy](https://leetcode.com/problems/bomb-enemy)| [Python](./python/361%20Bomb%20Enemy.py) [Java]() |Medium|| +|363|[Max Sum of Rectangle No Larger Than K](https://leetcode.com/problems/max-sum-of-rectangle-no-larger-than-k)| [Python](./python/363%20Max%20Sum%20of%20Rectangle%20No%20Larger%20Than%20K.py) [Java]() |Hard|| +|368|[Largest Divisible Subset](https://leetcode.com/problems/largest-divisible-subset)| [Python](./python/368%20Largest%20Divisible%20Subset.py) [Java]() |Medium|| +|375|[Guess Number Higher or Lower II](https://leetcode.com/problems/guess-number-higher-or-lower-ii)| [Python](./python/375%20Guess%20Number%20Higher%20or%20Lower%20II.py) [Java]() |Medium|| +|376|[Wiggle Subsequence](https://leetcode.com/problems/wiggle-subsequence)| [Python](./python/376%20Wiggle%20Subsequence.py) [Java]() |Medium|| +|377|[Combination Sum IV](https://leetcode.com/problems/combination-sum-iv)| [Python](./python/377%20Combination%20Sum%20IV.py) [Java]() |Medium|| +|392|[Is Subsequence](https://leetcode.com/problems/is-subsequence)| [Python](./python/392%20Is%20Subsequence.py) [Java]() |Medium|| +|403|[Frog Jump](https://leetcode.com/problems/frog-jump)| [Python](./python/403%20Frog%20Jump.py) [Java]() |Hard|| +|410|[Split Array Largest Sum](https://leetcode.com/problems/split-array-largest-sum)| [Python](./python/410%20Split%20Array%20Largest%20Sum.py) [Java]() |Hard|| +|413|[Arithmetic Slices](https://leetcode.com/problems/arithmetic-slices)| [Python](./python/413%20Arithmetic%20Slices.py) [Java]() |Medium|| +|416|[Partition Equal Subset Sum](https://leetcode.com/problems/partition-equal-subset-sum)| [Python](./python/416%20Partition%20Equal%20Subset%20Sum.py) [Java]() |Medium|| +|418|[Sentence Screen Fitting](https://leetcode.com/problems/sentence-screen-fitting)| [Python](./python/418%20Sentence%20Screen%20Fitting.py) [Java]() |Medium|| +|446|[Arithmetic Slices II - Subsequence](https://leetcode.com/problems/arithmetic-slices-ii---subsequence)| [Python](./python/446%20Arithmetic%20Slices%20II%20-%20Subsequence.py) [Java]() |Hard|| +|464|[Can I Win](https://leetcode.com/problems/can-i-win)| [Python](./python/464%20Can%20I%20Win.py) [Java]() |Medium|| +|466|[Count The Repetitions](https://leetcode.com/problems/count-the-repetitions)| [Python](./python/466%20Count%20The%20Repetitions.py) [Java]() |Hard|| +|467|[Unique Substrings in Wraparound String](https://leetcode.com/problems/unique-substrings-in-wraparound-string)| [Python](./python/467%20Unique%20Substrings%20in%20Wraparound%20String.py) [Java]() |Medium|| +|471|[Encode String with Shortest Length](https://leetcode.com/problems/encode-string-with-shortest-length)| [Python](./python/471%20Encode%20String%20with%20Shortest%20Length.py) [Java]() |Hard|| +|472|[Concatenated Words](https://leetcode.com/problems/concatenated-words)| [Python](./python/472%20Concatenated%20Words.py) [Java]() |Hard|| +|474|[Ones and Zeroes](https://leetcode.com/problems/ones-and-zeroes)| [Python](./python/474%20Ones%20and%20Zeroes.py) [Java]() |Medium|| +|486|[Predict the Winner](https://leetcode.com/problems/predict-the-winner)| [Python](./python/486%20Predict%20the%20Winner.py) [Java]() |Medium|| +|494|[Target Sum](https://leetcode.com/problems/target-sum)| [Python](./python/494%20Target%20Sum.py) [Java]() |Medium|| +|514|[Freedom Trail](https://leetcode.com/problems/freedom-trail)| [Python](./python/514%20Freedom%20Trail.py) [Java]() |Hard|| +|516|[Longest Palindromic Subsequence](https://leetcode.com/problems/longest-palindromic-subsequence)| [Python](./python/516%20Longest%20Palindromic%20Subsequence.py) [Java]() |Medium|| +|517|[Super Washing Machines](https://leetcode.com/problems/super-washing-machines)| [Python](./python/517%20Super%20Washing%20Machines.py) [Java]() |Hard|| +|523|[Continuous Subarray Sum](https://leetcode.com/problems/continuous-subarray-sum)| [Python](./python/523%20Continuous%20Subarray%20Sum.py) [Java]() |Medium|| +|546|[Remove Boxes](https://leetcode.com/problems/remove-boxes)| [Python](./python/546%20Remove%20Boxes.py) [Java]() |Hard|| +|552|[Student Attendance Record II](https://leetcode.com/problems/student-attendance-record-ii)| [Python](./python/552%20Student%20Attendance%20Record%20II.py) [Java]() |Hard|| +|568|[Maximum Vacation Days](https://leetcode.com/problems/maximum-vacation-days)| [Python](./python/568%20Maximum%20Vacation%20Days.py) [Java]() |Hard|| ## Backtracking | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|10|[Regular Expression Matching](https://leetcode.com/problems/regular-expression-matching)|[Python](./python/010 Regular Expression Matching.py) [Java]()|Hard|| -|17|[Letter Combinations of a Phone Number](https://leetcode.com/problems/letter-combinations-of-a-phone-number)|[Python](./python/017 Letter Combinations of a Phone Number.py) [Java]()|Medium|| -|22|[Generate Parentheses](https://leetcode.com/problems/generate-parentheses)|[Python](./python/022 Generate Parentheses.py) [Java]()|Medium|| -|37|[Sudoku Solver](https://leetcode.com/problems/sudoku-solver)|[Python](./python/037 Sudoku Solver.py) [Java]()|Hard|| -|39|[Combination Sum](https://leetcode.com/problems/combination-sum)|[Python](./python/039 Combination Sum.py) [Java]()|Medium|| -|40|[Combination Sum II](https://leetcode.com/problems/combination-sum-ii)|[Python](./python/040 Combination Sum II.py) [Java]()|Medium|| -|44|[Wildcard Matching](https://leetcode.com/problems/wildcard-matching)|[Python](./python/044 Wildcard Matching.py) [Java]()|Hard|| -|46|[Permutations](https://leetcode.com/problems/permutations)|[Python](./python/046 Permutations.py) [Java]()|Medium|| -|47|[Permutations II](https://leetcode.com/problems/permutations-ii)|[Python](./python/047 Permutations II.py) [Java]()|Medium|| -|51|[N-Queens](https://leetcode.com/problems/n-queens)|[Python](./python/051 N-Queens.py) [Java]()|Hard|| -|52|[N-Queens II](https://leetcode.com/problems/n-queens-ii)|[Python](./python/052 N-Queens II.py) [Java]()|Hard|| -|60|[Permutation Sequence](https://leetcode.com/problems/permutation-sequence)|[Python](./python/060 Permutation Sequence.py) [Java]()|Medium|| -|77|[Combinations](https://leetcode.com/problems/combinations)|[Python](./python/077 Combinations.py) [Java]()|Medium|| -|78|[Subsets](https://leetcode.com/problems/subsets)|[Python](./python/078 Subsets.py) [Java]()|Medium|| -|79|[Word Search](https://leetcode.com/problems/word-search)|[Python](./python/079 Word Search.py) [Java]()|Medium|| -|89|[Gray Code](https://leetcode.com/problems/gray-code)|[Python](./python/089 Gray Code.py) [Java]()|Medium|| -|90|[Subsets II](https://leetcode.com/problems/subsets-ii)|[Python](./python/090 Subsets II.py) [Java]()|Medium|| -|93|[Restore IP Addresses](https://leetcode.com/problems/restore-ip-addresses)|[Python](./python/093 Restore IP Addresses.py) [Java]()|Medium|| -|126|[Word Ladder II](https://leetcode.com/problems/word-ladder-ii)|[Python](./python/126 Word Ladder II.py) [Java]()|Hard|| -|131|[Palindrome Partitioning](https://leetcode.com/problems/palindrome-partitioning)|[Python](./python/131 Palindrome Partitioning.py) [Java]()|Medium|| -|140|[Word Break II](https://leetcode.com/problems/word-break-ii)|[Python](./python/140 Word Break II.py) [Java]()|Hard|| -|211|[Add and Search Word - Data structure design](https://leetcode.com/problems/add-and-search-word---data-structure-design)|[Python](./python/211 Add and Search Word - Data structure design.py) [Java]()|Medium|| -|212|[Word Search II](https://leetcode.com/problems/word-search-ii)|[Python](./python/212 Word Search II.py) [Java]()|Hard|| -|216|[Combination Sum III](https://leetcode.com/problems/combination-sum-iii)|[Python](./python/216 Combination Sum III.py) [Java]()|Medium|| -|254|[Factor Combinations](https://leetcode.com/problems/factor-combinations)|[Python](./python/254 Factor Combinations.py) [Java]()|Medium|| -|267|[Palindrome Permutation II](https://leetcode.com/problems/palindrome-permutation-ii)|[Python](./python/267 Palindrome Permutation II.py) [Java]()|Medium|| -|291|[Word Pattern II](https://leetcode.com/problems/word-pattern-ii)|[Python](./python/291 Word Pattern II.py) [Java]()|Hard|| -|294|[Flip Game II](https://leetcode.com/problems/flip-game-ii)|[Python](./python/294 Flip Game II.py) [Java]()|Medium|| -|320|[Generalized Abbreviation](https://leetcode.com/problems/generalized-abbreviation)|[Python](./python/320 Generalized Abbreviation.py) [Java]()|Medium|| -|351|[Android Unlock Patterns](https://leetcode.com/problems/android-unlock-patterns)|[Python](./python/351 Android Unlock Patterns.py) [Java]()|Medium|| -|357|[Count Numbers with Unique Digits](https://leetcode.com/problems/count-numbers-with-unique-digits)|[Python](./python/357 Count Numbers with Unique Digits.py) [Java]()|Medium|| -|401|[Binary Watch](https://leetcode.com/problems/binary-watch)|[Python](./python/401 Binary Watch.py) [Java]()|Easy|| -|411|[Minimum Unique Word Abbreviation](https://leetcode.com/problems/minimum-unique-word-abbreviation)|[Python](./python/411 Minimum Unique Word Abbreviation.py) [Java]()|Hard|| -|425|[Word Squares](https://leetcode.com/problems/word-squares)|[Python](./python/425 Word Squares.py) [Java]()|Hard|| -|526|[Beautiful Arrangement](https://leetcode.com/problems/beautiful-arrangement)|[Python](./python/526 Beautiful Arrangement.py) [Java]()|Medium|| +|10|[Regular Expression Matching](https://leetcode.com/problems/regular-expression-matching)| [Python](./python/010%20Regular%20Expression%20Matching.py) [Java]() |Hard|| +|17|[Letter Combinations of a Phone Number](https://leetcode.com/problems/letter-combinations-of-a-phone-number)| [Python](./python/017%20Letter%20Combinations%20of%20a%20Phone%20Number.py) [Java]() |Medium|| +|22|[Generate Parentheses](https://leetcode.com/problems/generate-parentheses)| [Python](./python/022%20Generate%20Parentheses.py) [Java]() |Medium|| +|37|[Sudoku Solver](https://leetcode.com/problems/sudoku-solver)| [Python](./python/037%20Sudoku%20Solver.py) [Java]() |Hard|| +|39|[Combination Sum](https://leetcode.com/problems/combination-sum)| [Python](./python/039%20Combination%20Sum.py) [Java]() |Medium|| +|40|[Combination Sum II](https://leetcode.com/problems/combination-sum-ii)| [Python](./python/040%20Combination%20Sum%20II.py) [Java]() |Medium|| +|44|[Wildcard Matching](https://leetcode.com/problems/wildcard-matching)| [Python](./python/044%20Wildcard%20Matching.py) [Java]() |Hard|| +|46|[Permutations](https://leetcode.com/problems/permutations)| [Python](./python/046%20Permutations.py) [Java]() |Medium|| +|47|[Permutations II](https://leetcode.com/problems/permutations-ii)| [Python](./python/047%20Permutations%20II.py) [Java]() |Medium|| +|51|[N-Queens](https://leetcode.com/problems/n-queens)| [Python](./python/051%20N-Queens.py) [Java]() |Hard|| +|52|[N-Queens II](https://leetcode.com/problems/n-queens-ii)| [Python](./python/052%20N-Queens%20II.py) [Java]() |Hard|| +|60|[Permutation Sequence](https://leetcode.com/problems/permutation-sequence)| [Python](./python/060%20Permutation%20Sequence.py) [Java]() |Medium|| +|77|[Combinations](https://leetcode.com/problems/combinations)| [Python](./python/077%20Combinations.py) [Java]() |Medium|| +|78|[Subsets](https://leetcode.com/problems/subsets)| [Python](./python/078%20Subsets.py) [Java]() |Medium|| +|79|[Word Search](https://leetcode.com/problems/word-search)| [Python](./python/079%20Word%20Search.py) [Java]() |Medium|| +|89|[Gray Code](https://leetcode.com/problems/gray-code)| [Python](./python/089%20Gray%20Code.py) [Java]() |Medium|| +|90|[Subsets II](https://leetcode.com/problems/subsets-ii)| [Python](./python/090%20Subsets%20II.py) [Java]() |Medium|| +|93|[Restore IP Addresses](https://leetcode.com/problems/restore-ip-addresses)| [Python](./python/093%20Restore%20IP%20Addresses.py) [Java]() |Medium|| +|126|[Word Ladder II](https://leetcode.com/problems/word-ladder-ii)| [Python](./python/126%20Word%20Ladder%20II.py) [Java]() |Hard|| +|131|[Palindrome Partitioning](https://leetcode.com/problems/palindrome-partitioning)| [Python](./python/131%20Palindrome%20Partitioning.py) [Java]() |Medium|| +|140|[Word Break II](https://leetcode.com/problems/word-break-ii)| [Python](./python/140%20Word%20Break%20II.py) [Java]() |Hard|| +|211|[Add and Search Word - Data structure design](https://leetcode.com/problems/add-and-search-word---data-structure-design)| [Python](./python/211%20Add%20and%20Search%20Word%20-%20Data%20structure%20design.py) [Java]() |Medium|| +|212|[Word Search II](https://leetcode.com/problems/word-search-ii)| [Python](./python/212%20Word%20Search%20II.py) [Java]() |Hard|| +|216|[Combination Sum III](https://leetcode.com/problems/combination-sum-iii)| [Python](./python/216%20Combination%20Sum%20III.py) [Java]() |Medium|| +|254|[Factor Combinations](https://leetcode.com/problems/factor-combinations)| [Python](./python/254%20Factor%20Combinations.py) [Java]() |Medium|| +|267|[Palindrome Permutation II](https://leetcode.com/problems/palindrome-permutation-ii)| [Python](./python/267%20Palindrome%20Permutation%20II.py) [Java]() |Medium|| +|291|[Word Pattern II](https://leetcode.com/problems/word-pattern-ii)| [Python](./python/291%20Word%20Pattern%20II.py) [Java]() |Hard|| +|294|[Flip Game II](https://leetcode.com/problems/flip-game-ii)| [Python](./python/294%20Flip%20Game%20II.py) [Java]() |Medium|| +|320|[Generalized Abbreviation](https://leetcode.com/problems/generalized-abbreviation)| [Python](./python/320%20Generalized%20Abbreviation.py) [Java]() |Medium|| +|351|[Android Unlock Patterns](https://leetcode.com/problems/android-unlock-patterns)| [Python](./python/351%20Android%20Unlock%20Patterns.py) [Java]() |Medium|| +|357|[Count Numbers with Unique Digits](https://leetcode.com/problems/count-numbers-with-unique-digits)| [Python](./python/357%20Count%20Numbers%20with%20Unique%20Digits.py) [Java]() |Medium|| +|401|[Binary Watch](https://leetcode.com/problems/binary-watch)| [Python](./python/401%20Binary%20Watch.py) [Java]() |Easy|| +|411|[Minimum Unique Word Abbreviation](https://leetcode.com/problems/minimum-unique-word-abbreviation)| [Python](./python/411%20Minimum%20Unique%20Word%20Abbreviation.py) [Java]() |Hard|| +|425|[Word Squares](https://leetcode.com/problems/word-squares)| [Python](./python/425%20Word%20Squares.py) [Java]() |Hard|| +|526|[Beautiful Arrangement](https://leetcode.com/problems/beautiful-arrangement)| [Python](./python/526%20Beautiful%20Arrangement.py) [Java]() |Medium|| ## Stack | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|20|[Valid Parentheses](https://leetcode.com/problems/valid-parentheses)|[Python](./python/020 Valid Parentheses.py) [Java]()|Easy|| -|42|[Trapping Rain Water](https://leetcode.com/problems/trapping-rain-water)|[Python](./python/042 Trapping Rain Water.py) [Java]()|Hard|| -|71|[Simplify Path](https://leetcode.com/problems/simplify-path)|[Python](./python/071 Simplify Path.py) [Java]()|Medium|| -|84|[Largest Rectangle in Histogram](https://leetcode.com/problems/largest-rectangle-in-histogram)|[Python](./python/084 Largest Rectangle in Histogram.py) [Java]()|Hard|| -|85|[Maximal Rectangle](https://leetcode.com/problems/maximal-rectangle)|[Python](./python/085 Maximal Rectangle.py) [Java]()|Hard|| -|94|[Binary Tree Inorder Traversal](https://leetcode.com/problems/binary-tree-inorder-traversal)|[Python](./python/094 Binary Tree Inorder Traversal.py) [Java]()|Medium|| -|103|[Binary Tree Zigzag Level Order Traversal](https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal)|[Python](./python/103 Binary Tree Zigzag Level Order Traversal.py) [Java]()|Medium|| -|144|[Binary Tree Preorder Traversal](https://leetcode.com/problems/binary-tree-preorder-traversal)|[Python](./python/144 Binary Tree Preorder Traversal.py) [Java]()|Medium|| -|145|[Binary Tree Postorder Traversal](https://leetcode.com/problems/binary-tree-postorder-traversal)|[Python](./python/145 Binary Tree Postorder Traversal.py) [Java]()|Hard|| -|150|[Evaluate Reverse Polish Notation](https://leetcode.com/problems/evaluate-reverse-polish-notation)|[Python](./python/150 Evaluate Reverse Polish Notation.py) [Java]()|Medium|| -|155|[Min Stack](https://leetcode.com/problems/min-stack)|[Python](./python/155 Min Stack.py) [Java]()|Easy|| -|173|[Binary Search Tree Iterator](https://leetcode.com/problems/binary-search-tree-iterator)|[Python](./python/173 Binary Search Tree Iterator.py) [Java]()|Medium|| -|224|[Basic Calculator](https://leetcode.com/problems/basic-calculator)|[Python](./python/224 Basic Calculator.py) [Java]()|Hard|| -|225|[Implement Stack using Queues](https://leetcode.com/problems/implement-stack-using-queues)|[Python](./python/225 Implement Stack using Queues.py) [Java]()|Easy|| -|232|[Implement Queue using Stacks](https://leetcode.com/problems/implement-queue-using-stacks)|[Python](./python/232 Implement Queue using Stacks.py) [Java]()|Easy|| -|255|[Verify Preorder Sequence in Binary Search Tree](https://leetcode.com/problems/verify-preorder-sequence-in-binary-search-tree)|[Python](./python/255 Verify Preorder Sequence in Binary Search Tree.py) [Java]()|Medium|| -|272|[Closest Binary Search Tree Value II](https://leetcode.com/problems/closest-binary-search-tree-value-ii)|[Python](./python/272 Closest Binary Search Tree Value II.py) [Java]()|Hard|| -|316|[Remove Duplicate Letters](https://leetcode.com/problems/remove-duplicate-letters)|[Python](./python/316 Remove Duplicate Letters.py) [Java]()|Hard|| -|331|[Verify Preorder Serialization of a Binary Tree](https://leetcode.com/problems/verify-preorder-serialization-of-a-binary-tree)|[Python](./python/331 Verify Preorder Serialization of a Binary Tree.py) [Java]()|Medium|| -|341|[Flatten Nested List Iterator](https://leetcode.com/problems/flatten-nested-list-iterator)|[Python](./python/341 Flatten Nested List Iterator.py) [Java]()|Medium|| -|385|[Mini Parser](https://leetcode.com/problems/mini-parser)|[Python](./python/385 Mini Parser.py) [Java]()|Medium|| -|394|[Decode String](https://leetcode.com/problems/decode-string)|[Python](./python/394 Decode String.py) [Java]()|Medium|| -|402|[Remove K Digits](https://leetcode.com/problems/remove-k-digits)|[Python](./python/402 Remove K Digits.py) [Java]()|Medium|| -|439|[Ternary Expression Parser](https://leetcode.com/problems/ternary-expression-parser)|[Python](./python/439 Ternary Expression Parser.py) [Java]()|Medium|| -|456|[132 Pattern](https://leetcode.com/problems/132-pattern)|[Python](./python/456 132 Pattern.py) [Java]()|Medium|| -|496|[Next Greater Element I](https://leetcode.com/problems/next-greater-element-i)|[Python](./python/496 Next Greater Element I.py) [Java]()|Easy|| -|503|[Next Greater Element II](https://leetcode.com/problems/next-greater-element-ii)|[Python](./python/503 Next Greater Element II.py) [Java]()|Medium|| +|20|[Valid Parentheses](https://leetcode.com/problems/valid-parentheses)| [Python](./python/020%20Valid%20Parentheses.py) [Java]() |Easy|| +|42|[Trapping Rain Water](https://leetcode.com/problems/trapping-rain-water)| [Python](./python/042%20Trapping%20Rain%20Water.py) [Java]() |Hard|| +|71|[Simplify Path](https://leetcode.com/problems/simplify-path)| [Python](./python/071%20Simplify%20Path.py) [Java]() |Medium|| +|84|[Largest Rectangle in Histogram](https://leetcode.com/problems/largest-rectangle-in-histogram)| [Python](./python/084%20Largest%20Rectangle%20in%20Histogram.py) [Java]() |Hard|| +|85|[Maximal Rectangle](https://leetcode.com/problems/maximal-rectangle)| [Python](./python/085%20Maximal%20Rectangle.py) [Java]() |Hard|| +|94|[Binary Tree Inorder Traversal](https://leetcode.com/problems/binary-tree-inorder-traversal)| [Python](./python/094%20Binary%20Tree%20Inorder%20Traversal.py) [Java]() |Medium|| +|103|[Binary Tree Zigzag Level Order Traversal](https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal)| [Python](./python/103%20Binary%20Tree%20Zigzag%20Level%20Order%20Traversal.py) [Java]() |Medium|| +|144|[Binary Tree Preorder Traversal](https://leetcode.com/problems/binary-tree-preorder-traversal)| [Python](./python/144%20Binary%20Tree%20Preorder%20Traversal.py) [Java]() |Medium|| +|145|[Binary Tree Postorder Traversal](https://leetcode.com/problems/binary-tree-postorder-traversal)| [Python](./python/145%20Binary%20Tree%20Postorder%20Traversal.py) [Java]() |Hard|| +|150|[Evaluate Reverse Polish Notation](https://leetcode.com/problems/evaluate-reverse-polish-notation)| [Python](./python/150%20Evaluate%20Reverse%20Polish%20Notation.py) [Java]() |Medium|| +|155|[Min Stack](https://leetcode.com/problems/min-stack)| [Python](./python/155%20Min%20Stack.py) [Java]() |Easy|| +|173|[Binary Search Tree Iterator](https://leetcode.com/problems/binary-search-tree-iterator)| [Python](./python/173%20Binary%20Search%20Tree%20Iterator.py) [Java]() |Medium|| +|224|[Basic Calculator](https://leetcode.com/problems/basic-calculator)| [Python](./python/224%20Basic%20Calculator.py) [Java]() |Hard|| +|225|[Implement Stack using Queues](https://leetcode.com/problems/implement-stack-using-queues)| [Python](./python/225%20Implement%20Stack%20using%20Queues.py) [Java]() |Easy|| +|232|[Implement Queue using Stacks](https://leetcode.com/problems/implement-queue-using-stacks)| [Python](./python/232%20Implement%20Queue%20using%20Stacks.py) [Java]() |Easy|| +|255|[Verify Preorder Sequence in Binary Search Tree](https://leetcode.com/problems/verify-preorder-sequence-in-binary-search-tree)| [Python](./python/255%20Verify%20Preorder%20Sequence%20in%20Binary%20Search%20Tree.py) [Java]() |Medium|| +|272|[Closest Binary Search Tree Value II](https://leetcode.com/problems/closest-binary-search-tree-value-ii)| [Python](./python/272%20Closest%20Binary%20Search%20Tree%20Value%20II.py) [Java]() |Hard|| +|316|[Remove Duplicate Letters](https://leetcode.com/problems/remove-duplicate-letters)| [Python](./python/316%20Remove%20Duplicate%20Letters.py) [Java]() |Hard|| +|331|[Verify Preorder Serialization of a Binary Tree](https://leetcode.com/problems/verify-preorder-serialization-of-a-binary-tree)| [Python](./python/331%20Verify%20Preorder%20Serialization%20of%20a%20Binary%20Tree.py) [Java]() |Medium|| +|341|[Flatten Nested List Iterator](https://leetcode.com/problems/flatten-nested-list-iterator)| [Python](./python/341%20Flatten%20Nested%20List%20Iterator.py) [Java]() |Medium|| +|385|[Mini Parser](https://leetcode.com/problems/mini-parser)| [Python](./python/385%20Mini%20Parser.py) [Java]() |Medium|| +|394|[Decode String](https://leetcode.com/problems/decode-string)| [Python](./python/394%20Decode%20String.py) [Java]() |Medium|| +|402|[Remove K Digits](https://leetcode.com/problems/remove-k-digits)| [Python](./python/402%20Remove%20K%20Digits.py) [Java]() |Medium|| +|439|[Ternary Expression Parser](https://leetcode.com/problems/ternary-expression-parser)| [Python](./python/439%20Ternary%20Expression%20Parser.py) [Java]() |Medium|| +|456|[132 Pattern](https://leetcode.com/problems/132-pattern)| [Python](./python/456%20132%20Pattern.py) [Java]() |Medium|| +|496|[Next Greater Element I](https://leetcode.com/problems/next-greater-element-i)| [Python](./python/496%20Next%20Greater%20Element%20I.py) [Java]() |Easy|| +|503|[Next Greater Element II](https://leetcode.com/problems/next-greater-element-ii)| [Python](./python/503%20Next%20Greater%20Element%20II.py) [Java]() |Medium|| ## Heap | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|23|[Merge k Sorted Lists](https://leetcode.com/problems/merge-k-sorted-lists)|[Python](./python/023 Merge k Sorted Lists.py) [Java]()|Hard|| -|215|[Kth Largest Element in an Array](https://leetcode.com/problems/kth-largest-element-in-an-array)|[Python](./python/215 Kth Largest Element in an Array.py) [Java]()|Medium|| -|218|[The Skyline Problem](https://leetcode.com/problems/the-skyline-problem)|[Python](./python/218 The Skyline Problem.py) [Java]()|Hard|| -|239|[Sliding Window Maximum](https://leetcode.com/problems/sliding-window-maximum)|[Python](./python/239 Sliding Window Maximum.py) [Java]()|Hard|| -|253|[Meeting Rooms II](https://leetcode.com/problems/meeting-rooms-ii)|[Python](./python/253 Meeting Rooms II.py) [Java]()|Medium|| -|264|[Ugly Number II](https://leetcode.com/problems/ugly-number-ii)|[Python](./python/264 Ugly Number II.py) [Java]()|Medium|| -|295|[Find Median from Data Stream](https://leetcode.com/problems/find-median-from-data-stream)|[Python](./python/295 Find Median from Data Stream.py) [Java]()|Hard|| -|313|[Super Ugly Number](https://leetcode.com/problems/super-ugly-number)|[Python](./python/313 Super Ugly Number.py) [Java]()|Medium|| -|347|[Top K Frequent Elements](https://leetcode.com/problems/top-k-frequent-elements)|[Python](./python/347 Top K Frequent Elements.py) [Java]()|Medium|| -|355|[Design Twitter](https://leetcode.com/problems/design-twitter)|[Python](./python/355 Design Twitter.py) [Java]()|Medium|| -|358|[Rearrange String k Distance Apart](https://leetcode.com/problems/rearrange-string-k-distance-apart)|[Python](./python/358 Rearrange String k Distance Apart.py) [Java]()|Hard|| -|373|[Find K Pairs with Smallest Sums](https://leetcode.com/problems/find-k-pairs-with-smallest-sums)|[Python](./python/373 Find K Pairs with Smallest Sums.py) [Java]()|Medium|| -|378|[Kth Smallest Element in a Sorted Matrix](https://leetcode.com/problems/kth-smallest-element-in-a-sorted-matrix)|[Python](./python/378 Kth Smallest Element in a Sorted Matrix.py) [Java]()|Medium|| -|407|[Trapping Rain Water II](https://leetcode.com/problems/trapping-rain-water-ii)|[Python](./python/407 Trapping Rain Water II.py) [Java]()|Hard|| -|451|[Sort Characters By Frequency](https://leetcode.com/problems/sort-characters-by-frequency)|[Python](./python/451 Sort Characters By Frequency.py) [Java]()|Medium|| -|502|[IPO](https://leetcode.com/problems/ipo)|[Python](./python/502 IPO.py) [Java]()|Hard|| +|23|[Merge k Sorted Lists](https://leetcode.com/problems/merge-k-sorted-lists)| [Python](./python/023%20Merge%20k%20Sorted%20Lists.py) [Java]() |Hard|| +|215|[Kth Largest Element in an Array](https://leetcode.com/problems/kth-largest-element-in-an-array)| [Python](./python/215%20Kth%20Largest%20Element%20in%20an%20Array.py) [Java]() |Medium|| +|218|[The Skyline Problem](https://leetcode.com/problems/the-skyline-problem)| [Python](./python/218%20The%20Skyline%20Problem.py) [Java]() |Hard|| +|239|[Sliding Window Maximum](https://leetcode.com/problems/sliding-window-maximum)| [Python](./python/239%20Sliding%20Window%20Maximum.py) [Java]() |Hard|| +|253|[Meeting Rooms II](https://leetcode.com/problems/meeting-rooms-ii)| [Python](./python/253%20Meeting%20Rooms%20II.py) [Java]() |Medium|| +|264|[Ugly Number II](https://leetcode.com/problems/ugly-number-ii)| [Python](./python/264%20Ugly%20Number%20II.py) [Java]() |Medium|| +|295|[Find Median from Data Stream](https://leetcode.com/problems/find-median-from-data-stream)| [Python](./python/295%20Find%20Median%20from%20Data%20Stream.py) [Java]() |Hard|| +|313|[Super Ugly Number](https://leetcode.com/problems/super-ugly-number)| [Python](./python/313%20Super%20Ugly%20Number.py) [Java]() |Medium|| +|347|[Top K Frequent Elements](https://leetcode.com/problems/top-k-frequent-elements)| [Python](./python/347%20Top%20K%20Frequent%20Elements.py) [Java]() |Medium|| +|355|[Design Twitter](https://leetcode.com/problems/design-twitter)| [Python](./python/355%20Design%20Twitter.py) [Java]() |Medium|| +|358|[Rearrange String k Distance Apart](https://leetcode.com/problems/rearrange-string-k-distance-apart)| [Python](./python/358%20Rearrange%20String%20k%20Distance%20Apart.py) [Java]() |Hard|| +|373|[Find K Pairs with Smallest Sums](https://leetcode.com/problems/find-k-pairs-with-smallest-sums)| [Python](./python/373%20Find%20K%20Pairs%20with%20Smallest%20Sums.py) [Java]() |Medium|| +|378|[Kth Smallest Element in a Sorted Matrix](https://leetcode.com/problems/kth-smallest-element-in-a-sorted-matrix)| [Python](./python/378%20Kth%20Smallest%20Element%20in%20a%20Sorted%20Matrix.py) [Java]() |Medium|| +|407|[Trapping Rain Water II](https://leetcode.com/problems/trapping-rain-water-ii)| [Python](./python/407%20Trapping%20Rain%20Water%20II.py) [Java]() |Hard|| +|451|[Sort Characters By Frequency](https://leetcode.com/problems/sort-characters-by-frequency)| [Python](./python/451%20Sort%20Characters%20By%20Frequency.py) [Java]() |Medium|| +|502|[IPO](https://leetcode.com/problems/ipo)| [Python](./python/502%20IPO.py) [Java]() |Hard|| ## Tree | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|94|[Binary Tree Inorder Traversal](https://leetcode.com/problems/binary-tree-inorder-traversal)|[Python](./python/094 Binary Tree Inorder Traversal.py) [Java]()|Medium|| -|95|[Unique Binary Search Trees II](https://leetcode.com/problems/unique-binary-search-trees-ii)|[Python](./python/095 Unique Binary Search Trees II.py) [Java]()|Medium|| -|96|[Unique Binary Search Trees](https://leetcode.com/problems/unique-binary-search-trees)|[Python](./python/096 Unique Binary Search Trees.py) [Java]()|Medium|| -|98|[Validate Binary Search Tree](https://leetcode.com/problems/validate-binary-search-tree)|[Python](./python/098 Validate Binary Search Tree.py) [Java]()|Medium|| -|99|[Recover Binary Search Tree](https://leetcode.com/problems/recover-binary-search-tree)|[Python](./python/099 Recover Binary Search Tree.py) [Java]()|Hard|| -|100|[Same Tree](https://leetcode.com/problems/same-tree)|[Python](./python/100 Same Tree.py) [Java]()|Easy|| -|101|[Symmetric Tree](https://leetcode.com/problems/symmetric-tree)|[Python](./python/101 Symmetric Tree.py) [Java]()|Easy|| -|102|[Binary Tree Level Order Traversal](https://leetcode.com/problems/binary-tree-level-order-traversal)|[Python](./python/102 Binary Tree Level Order Traversal.py) [Java]()|Medium|| -|103|[Binary Tree Zigzag Level Order Traversal](https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal)|[Python](./python/103 Binary Tree Zigzag Level Order Traversal.py) [Java]()|Medium|| -|104|[Maximum Depth of Binary Tree](https://leetcode.com/problems/maximum-depth-of-binary-tree)|[Python](./python/104 Maximum Depth of Binary Tree.py) [Java]()|Easy|| -|105|[Construct Binary Tree from Preorder and Inorder Traversal](https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal)|[Python](./python/105 Construct Binary Tree from Preorder and Inorder Traversal.py) [Java]()|Medium|| -|106|[Construct Binary Tree from Inorder and Postorder Traversal](https://leetcode.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal)|[Python](./python/106 Construct Binary Tree from Inorder and Postorder Traversal.py) [Java]()|Medium|| -|107|[Binary Tree Level Order Traversal II](https://leetcode.com/problems/binary-tree-level-order-traversal-ii)|[Python](./python/107 Binary Tree Level Order Traversal II.py) [Java]()|Easy|| -|108|[Convert Sorted Array to Binary Search Tree](https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree)|[Python](./python/108 Convert Sorted Array to Binary Search Tree.py) [Java]()|Easy|| -|110|[Balanced Binary Tree](https://leetcode.com/problems/balanced-binary-tree)|[Python](./python/110 Balanced Binary Tree.py) [Java]()|Easy|| -|111|[Minimum Depth of Binary Tree](https://leetcode.com/problems/minimum-depth-of-binary-tree)|[Python](./python/111 Minimum Depth of Binary Tree.py) [Java]()|Easy|| -|112|[Path Sum](https://leetcode.com/problems/path-sum)|[Python](./python/112 Path Sum.py) [Java]()|Easy|| -|113|[Path Sum II](https://leetcode.com/problems/path-sum-ii)|[Python](./python/113 Path Sum II.py) [Java]()|Medium|| -|114|[Flatten Binary Tree to Linked List](https://leetcode.com/problems/flatten-binary-tree-to-linked-list)|[Python](./python/114 Flatten Binary Tree to Linked List.py) [Java]()|Medium|| -|116|[Populating Next Right Pointers in Each Node](https://leetcode.com/problems/populating-next-right-pointers-in-each-node)|[Python](./python/116 Populating Next Right Pointers in Each Node.py) [Java]()|Medium|| -|117|[Populating Next Right Pointers in Each Node II](https://leetcode.com/problems/populating-next-right-pointers-in-each-node-ii)|[Python](./python/117 Populating Next Right Pointers in Each Node II.py) [Java]()|Medium|| -|124|[Binary Tree Maximum Path Sum](https://leetcode.com/problems/binary-tree-maximum-path-sum)|[Python](./python/124 Binary Tree Maximum Path Sum.py) [Java]()|Hard|| -|129|[Sum Root to Leaf Numbers](https://leetcode.com/problems/sum-root-to-leaf-numbers)|[Python](./python/129 Sum Root to Leaf Numbers.py) [Java]()|Medium|| -|144|[Binary Tree Preorder Traversal](https://leetcode.com/problems/binary-tree-preorder-traversal)|[Python](./python/144 Binary Tree Preorder Traversal.py) [Java]()|Medium|| -|145|[Binary Tree Postorder Traversal](https://leetcode.com/problems/binary-tree-postorder-traversal)|[Python](./python/145 Binary Tree Postorder Traversal.py) [Java]()|Hard|| -|156|[Binary Tree Upside Down](https://leetcode.com/problems/binary-tree-upside-down)|[Python](./python/156 Binary Tree Upside Down.py) [Java]()|Medium|| -|173|[Binary Search Tree Iterator](https://leetcode.com/problems/binary-search-tree-iterator)|[Python](./python/173 Binary Search Tree Iterator.py) [Java]()|Medium|| -|199|[Binary Tree Right Side View](https://leetcode.com/problems/binary-tree-right-side-view)|[Python](./python/199 Binary Tree Right Side View.py) [Java]()|Medium|| -|222|[Count Complete Tree Nodes](https://leetcode.com/problems/count-complete-tree-nodes)|[Python](./python/222 Count Complete Tree Nodes.py) [Java]()|Medium|| -|226|[Invert Binary Tree](https://leetcode.com/problems/invert-binary-tree)|[Python](./python/226 Invert Binary Tree.py) [Java]()|Easy|| -|230|[Kth Smallest Element in a BST](https://leetcode.com/problems/kth-smallest-element-in-a-bst)|[Python](./python/230 Kth Smallest Element in a BST.py) [Java]()|Medium|| -|235|[Lowest Common Ancestor of a Binary Search Tree](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree)|[Python](./python/235 Lowest Common Ancestor of a Binary Search Tree.py) [Java]()|Easy|| -|236|[Lowest Common Ancestor of a Binary Tree](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree)|[Python](./python/236 Lowest Common Ancestor of a Binary Tree.py) [Java]()|Medium|| -|250|[Count Univalue Subtrees](https://leetcode.com/problems/count-univalue-subtrees)|[Python](./python/250 Count Univalue Subtrees.py) [Java]()|Medium|| -|255|[Verify Preorder Sequence in Binary Search Tree](https://leetcode.com/problems/verify-preorder-sequence-in-binary-search-tree)|[Python](./python/255 Verify Preorder Sequence in Binary Search Tree.py) [Java]()|Medium|| -|257|[Binary Tree Paths](https://leetcode.com/problems/binary-tree-paths)|[Python](./python/257 Binary Tree Paths.py) [Java]()|Easy|| -|270|[Closest Binary Search Tree Value](https://leetcode.com/problems/closest-binary-search-tree-value)|[Python](./python/270 Closest Binary Search Tree Value.py) [Java]()|Easy|| -|272|[Closest Binary Search Tree Value II](https://leetcode.com/problems/closest-binary-search-tree-value-ii)|[Python](./python/272 Closest Binary Search Tree Value II.py) [Java]()|Hard|| -|285|[Inorder Successor in BST](https://leetcode.com/problems/inorder-successor-in-bst)|[Python](./python/285 Inorder Successor in BST.py) [Java]()|Medium|| -|297|[Serialize and Deserialize Binary Tree](https://leetcode.com/problems/serialize-and-deserialize-binary-tree)|[Python](./python/297 Serialize and Deserialize Binary Tree.py) [Java]()|Hard|| -|298|[Binary Tree Longest Consecutive Sequence](https://leetcode.com/problems/binary-tree-longest-consecutive-sequence)|[Python](./python/298 Binary Tree Longest Consecutive Sequence.py) [Java]()|Medium|| -|333|[Largest BST Subtree](https://leetcode.com/problems/largest-bst-subtree)|[Python](./python/333 Largest BST Subtree.py) [Java]()|Medium|| -|337|[House Robber III](https://leetcode.com/problems/house-robber-iii)|[Python](./python/337 House Robber III.py) [Java]()|Medium|| -|366|[Find Leaves of Binary Tree](https://leetcode.com/problems/find-leaves-of-binary-tree)|[Python](./python/366 Find Leaves of Binary Tree.py) [Java]()|Medium|| -|404|[Sum of Left Leaves](https://leetcode.com/problems/sum-of-left-leaves)|[Python](./python/404 Sum of Left Leaves.py) [Java]()|Easy|| -|437|[Path Sum III](https://leetcode.com/problems/path-sum-iii)|[Python](./python/437 Path Sum III.py) [Java]()|Easy|| -|449|[Serialize and Deserialize BST](https://leetcode.com/problems/serialize-and-deserialize-bst)|[Python](./python/449 Serialize and Deserialize BST.py) [Java]()|Medium|| -|450|[Delete Node in a BST](https://leetcode.com/problems/delete-node-in-a-bst)|[Python](./python/450 Delete Node in a BST.py) [Java]()|Medium|| -|501|[Find Mode in Binary Search Tree](https://leetcode.com/problems/find-mode-in-binary-search-tree)|[Python](./python/501 Find Mode in Binary Search Tree.py) [Java]()|Easy|| -|508|[Most Frequent Subtree Sum](https://leetcode.com/problems/most-frequent-subtree-sum)|[Python](./python/508 Most Frequent Subtree Sum.py) [Java]()|Medium|| -|513|[Find Bottom Left Tree Value](https://leetcode.com/problems/find-bottom-left-tree-value)|[Python](./python/513 Find Bottom Left Tree Value.py) [Java]()|Medium|| -|515|[Find Largest Value in Each Tree Row](https://leetcode.com/problems/find-largest-value-in-each-tree-row)|[Python](./python/515 Find Largest Value in Each Tree Row.py) [Java]()|Medium|| -|536|[Construct Binary Tree from String](https://leetcode.com/problems/construct-binary-tree-from-string)|[Python](./python/536 Construct Binary Tree from String.py) [Java]()|Medium|| -|538|[Convert BST to Greater Tree](https://leetcode.com/problems/convert-bst-to-greater-tree)|[Python](./python/538 Convert BST to Greater Tree.py) [Java]()|Medium|| -|543|[Diameter of Binary Tree](https://leetcode.com/problems/diameter-of-binary-tree)|[Python](./python/543 Diameter of Binary Tree.py) [Java]()|Easy|| -|545|[Boundary of Binary Tree](https://leetcode.com/problems/boundary-of-binary-tree)|[Python](./python/545 Boundary of Binary Tree.py) [Java]()|Medium|| -|549|[Binary Tree Longest Consecutive Sequence II](https://leetcode.com/problems/binary-tree-longest-consecutive-sequence-ii)|[Python](./python/549 Binary Tree Longest Consecutive Sequence II.py) [Java]()|Medium|| -|563|[Binary Tree Tilt](https://leetcode.com/problems/binary-tree-tilt)|[Python](./python/563 Binary Tree Tilt.py) [Java]()|Easy|| +|94|[Binary Tree Inorder Traversal](https://leetcode.com/problems/binary-tree-inorder-traversal)| [Python](./python/094%20Binary%20Tree%20Inorder%20Traversal.py) [Java]() |Medium|| +|95|[Unique Binary Search Trees II](https://leetcode.com/problems/unique-binary-search-trees-ii)| [Python](./python/095%20Unique%20Binary%20Search%20Trees%20II.py) [Java]() |Medium|| +|96|[Unique Binary Search Trees](https://leetcode.com/problems/unique-binary-search-trees)| [Python](./python/096%20Unique%20Binary%20Search%20Trees.py) [Java]() |Medium|| +|98|[Validate Binary Search Tree](https://leetcode.com/problems/validate-binary-search-tree)| [Python](./python/098%20Validate%20Binary%20Search%20Tree.py) [Java]() |Medium|| +|99|[Recover Binary Search Tree](https://leetcode.com/problems/recover-binary-search-tree)| [Python](./python/099%20Recover%20Binary%20Search%20Tree.py) [Java]() |Hard|| +|100|[Same Tree](https://leetcode.com/problems/same-tree)| [Python](./python/100%20Same%20Tree.py) [Java]() |Easy|| +|101|[Symmetric Tree](https://leetcode.com/problems/symmetric-tree)| [Python](./python/101%20Symmetric%20Tree.py) [Java]() |Easy|| +|102|[Binary Tree Level Order Traversal](https://leetcode.com/problems/binary-tree-level-order-traversal)| [Python](./python/102%20Binary%20Tree%20Level%20Order%20Traversal.py) [Java]() |Medium|| +|103|[Binary Tree Zigzag Level Order Traversal](https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal)| [Python](./python/103%20Binary%20Tree%20Zigzag%20Level%20Order%20Traversal.py) [Java]() |Medium|| +|104|[Maximum Depth of Binary Tree](https://leetcode.com/problems/maximum-depth-of-binary-tree)| [Python](./python/104%20Maximum%20Depth%20of%20Binary%20Tree.py) [Java]() |Easy|| +|105|[Construct Binary Tree from Preorder and Inorder Traversal](https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal)| [Python](./python/105%20Construct%20Binary%20Tree%20from%20Preorder%20and%20Inorder%20Traversal.py) [Java]() |Medium|| +|106|[Construct Binary Tree from Inorder and Postorder Traversal](https://leetcode.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal)| [Python](./python/106%20Construct%20Binary%20Tree%20from%20Inorder%20and%20Postorder%20Traversal.py) [Java]() |Medium|| +|107|[Binary Tree Level Order Traversal II](https://leetcode.com/problems/binary-tree-level-order-traversal-ii)| [Python](./python/107%20Binary%20Tree%20Level%20Order%20Traversal%20II.py) [Java]() |Easy|| +|108|[Convert Sorted Array to Binary Search Tree](https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree)| [Python](./python/108%20Convert%20Sorted%20Array%20to%20Binary%20Search%20Tree.py) [Java]() |Easy|| +|110|[Balanced Binary Tree](https://leetcode.com/problems/balanced-binary-tree)| [Python](./python/110%20Balanced%20Binary%20Tree.py) [Java]() |Easy|| +|111|[Minimum Depth of Binary Tree](https://leetcode.com/problems/minimum-depth-of-binary-tree)| [Python](./python/111%20Minimum%20Depth%20of%20Binary%20Tree.py) [Java]() |Easy|| +|112|[Path Sum](https://leetcode.com/problems/path-sum)| [Python](./python/112%20Path%20Sum.py) [Java]() |Easy|| +|113|[Path Sum II](https://leetcode.com/problems/path-sum-ii)| [Python](./python/113%20Path%20Sum%20II.py) [Java]() |Medium|| +|114|[Flatten Binary Tree to Linked List](https://leetcode.com/problems/flatten-binary-tree-to-linked-list)| [Python](./python/114%20Flatten%20Binary%20Tree%20to%20Linked%20List.py) [Java]() |Medium|| +|116|[Populating Next Right Pointers in Each Node](https://leetcode.com/problems/populating-next-right-pointers-in-each-node)| [Python](./python/116%20Populating%20Next%20Right%20Pointers%20in%20Each%20Node.py) [Java]() |Medium|| +|117|[Populating Next Right Pointers in Each Node II](https://leetcode.com/problems/populating-next-right-pointers-in-each-node-ii)| [Python](./python/117%20Populating%20Next%20Right%20Pointers%20in%20Each%20Node%20II.py) [Java]() |Medium|| +|124|[Binary Tree Maximum Path Sum](https://leetcode.com/problems/binary-tree-maximum-path-sum)| [Python](./python/124%20Binary%20Tree%20Maximum%20Path%20Sum.py) [Java]() |Hard|| +|129|[Sum Root to Leaf Numbers](https://leetcode.com/problems/sum-root-to-leaf-numbers)| [Python](./python/129%20Sum%20Root%20to%20Leaf%20Numbers.py) [Java]() |Medium|| +|144|[Binary Tree Preorder Traversal](https://leetcode.com/problems/binary-tree-preorder-traversal)| [Python](./python/144%20Binary%20Tree%20Preorder%20Traversal.py) [Java]() |Medium|| +|145|[Binary Tree Postorder Traversal](https://leetcode.com/problems/binary-tree-postorder-traversal)| [Python](./python/145%20Binary%20Tree%20Postorder%20Traversal.py) [Java]() |Hard|| +|156|[Binary Tree Upside Down](https://leetcode.com/problems/binary-tree-upside-down)| [Python](./python/156%20Binary%20Tree%20Upside%20Down.py) [Java]() |Medium|| +|173|[Binary Search Tree Iterator](https://leetcode.com/problems/binary-search-tree-iterator)| [Python](./python/173%20Binary%20Search%20Tree%20Iterator.py) [Java]() |Medium|| +|199|[Binary Tree Right Side View](https://leetcode.com/problems/binary-tree-right-side-view)| [Python](./python/199%20Binary%20Tree%20Right%20Side%20View.py) [Java]() |Medium|| +|222|[Count Complete Tree Nodes](https://leetcode.com/problems/count-complete-tree-nodes)| [Python](./python/222%20Count%20Complete%20Tree%20Nodes.py) [Java]() |Medium|| +|226|[Invert Binary Tree](https://leetcode.com/problems/invert-binary-tree)| [Python](./python/226%20Invert%20Binary%20Tree.py) [Java]() |Easy|| +|230|[Kth Smallest Element in a BST](https://leetcode.com/problems/kth-smallest-element-in-a-bst)| [Python](./python/230%20Kth%20Smallest%20Element%20in%20a%20BST.py) [Java]() |Medium|| +|235|[Lowest Common Ancestor of a Binary Search Tree](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree)| [Python](./python/235%20Lowest%20Common%20Ancestor%20of%20a%20Binary%20Search%20Tree.py) [Java]() |Easy|| +|236|[Lowest Common Ancestor of a Binary Tree](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree)| [Python](./python/236%20Lowest%20Common%20Ancestor%20of%20a%20Binary%20Tree.py) [Java]() |Medium|| +|250|[Count Univalue Subtrees](https://leetcode.com/problems/count-univalue-subtrees)| [Python](./python/250%20Count%20Univalue%20Subtrees.py) [Java]() |Medium|| +|255|[Verify Preorder Sequence in Binary Search Tree](https://leetcode.com/problems/verify-preorder-sequence-in-binary-search-tree)| [Python](./python/255%20Verify%20Preorder%20Sequence%20in%20Binary%20Search%20Tree.py) [Java]() |Medium|| +|257|[Binary Tree Paths](https://leetcode.com/problems/binary-tree-paths)| [Python](./python/257%20Binary%20Tree%20Paths.py) [Java]() |Easy|| +|270|[Closest Binary Search Tree Value](https://leetcode.com/problems/closest-binary-search-tree-value)| [Python](./python/270%20Closest%20Binary%20Search%20Tree%20Value.py) [Java]() |Easy|| +|272|[Closest Binary Search Tree Value II](https://leetcode.com/problems/closest-binary-search-tree-value-ii)| [Python](./python/272%20Closest%20Binary%20Search%20Tree%20Value%20II.py) [Java]() |Hard|| +|285|[Inorder Successor in BST](https://leetcode.com/problems/inorder-successor-in-bst)| [Python](./python/285%20Inorder%20Successor%20in%20BST.py) [Java]() |Medium|| +|297|[Serialize and Deserialize Binary Tree](https://leetcode.com/problems/serialize-and-deserialize-binary-tree)| [Python](./python/297%20Serialize%20and%20Deserialize%20Binary%20Tree.py) [Java]() |Hard|| +|298|[Binary Tree Longest Consecutive Sequence](https://leetcode.com/problems/binary-tree-longest-consecutive-sequence)| [Python](./python/298%20Binary%20Tree%20Longest%20Consecutive%20Sequence.py) [Java]() |Medium|| +|333|[Largest BST Subtree](https://leetcode.com/problems/largest-bst-subtree)| [Python](./python/333%20Largest%20BST%20Subtree.py) [Java]() |Medium|| +|337|[House Robber III](https://leetcode.com/problems/house-robber-iii)| [Python](./python/337%20House%20Robber%20III.py) [Java]() |Medium|| +|366|[Find Leaves of Binary Tree](https://leetcode.com/problems/find-leaves-of-binary-tree)| [Python](./python/366%20Find%20Leaves%20of%20Binary%20Tree.py) [Java]() |Medium|| +|404|[Sum of Left Leaves](https://leetcode.com/problems/sum-of-left-leaves)| [Python](./python/404%20Sum%20of%20Left%20Leaves.py) [Java]() |Easy|| +|437|[Path Sum III](https://leetcode.com/problems/path-sum-iii)| [Python](./python/437%20Path%20Sum%20III.py) [Java]() |Easy|| +|449|[Serialize and Deserialize BST](https://leetcode.com/problems/serialize-and-deserialize-bst)| [Python](./python/449%20Serialize%20and%20Deserialize%20BST.py) [Java]() |Medium|| +|450|[Delete Node in a BST](https://leetcode.com/problems/delete-node-in-a-bst)| [Python](./python/450%20Delete%20Node%20in%20a%20BST.py) [Java]() |Medium|| +|501|[Find Mode in Binary Search Tree](https://leetcode.com/problems/find-mode-in-binary-search-tree)| [Python](./python/501%20Find%20Mode%20in%20Binary%20Search%20Tree.py) [Java]() |Easy|| +|508|[Most Frequent Subtree Sum](https://leetcode.com/problems/most-frequent-subtree-sum)| [Python](./python/508%20Most%20Frequent%20Subtree%20Sum.py) [Java]() |Medium|| +|513|[Find Bottom Left Tree Value](https://leetcode.com/problems/find-bottom-left-tree-value)| [Python](./python/513%20Find%20Bottom%20Left%20Tree%20Value.py) [Java]() |Medium|| +|515|[Find Largest Value in Each Tree Row](https://leetcode.com/problems/find-largest-value-in-each-tree-row)| [Python](./python/515%20Find%20Largest%20Value%20in%20Each%20Tree%20Row.py) [Java]() |Medium|| +|536|[Construct Binary Tree from String](https://leetcode.com/problems/construct-binary-tree-from-string)| [Python](./python/536%20Construct%20Binary%20Tree%20from%20String.py) [Java]() |Medium|| +|538|[Convert BST to Greater Tree](https://leetcode.com/problems/convert-bst-to-greater-tree)| [Python](./python/538%20Convert%20BST%20to%20Greater%20Tree.py) [Java]() |Medium|| +|543|[Diameter of Binary Tree](https://leetcode.com/problems/diameter-of-binary-tree)| [Python](./python/543%20Diameter%20of%20Binary%20Tree.py) [Java]() |Easy|| +|545|[Boundary of Binary Tree](https://leetcode.com/problems/boundary-of-binary-tree)| [Python](./python/545%20Boundary%20of%20Binary%20Tree.py) [Java]() |Medium|| +|549|[Binary Tree Longest Consecutive Sequence II](https://leetcode.com/problems/binary-tree-longest-consecutive-sequence-ii)| [Python](./python/549%20Binary%20Tree%20Longest%20Consecutive%20Sequence%20II.py) [Java]() |Medium|| +|563|[Binary Tree Tilt](https://leetcode.com/problems/binary-tree-tilt)| [Python](./python/563%20Binary%20Tree%20Tilt.py) [Java]() |Easy|| ## Depth-first Search | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|98|[Validate Binary Search Tree](https://leetcode.com/problems/validate-binary-search-tree)|[Python](./python/098 Validate Binary Search Tree.py) [Java]()|Medium|| -|99|[Recover Binary Search Tree](https://leetcode.com/problems/recover-binary-search-tree)|[Python](./python/099 Recover Binary Search Tree.py) [Java]()|Hard|| -|100|[Same Tree](https://leetcode.com/problems/same-tree)|[Python](./python/100 Same Tree.py) [Java]()|Easy|| -|101|[Symmetric Tree](https://leetcode.com/problems/symmetric-tree)|[Python](./python/101 Symmetric Tree.py) [Java]()|Easy|| -|104|[Maximum Depth of Binary Tree](https://leetcode.com/problems/maximum-depth-of-binary-tree)|[Python](./python/104 Maximum Depth of Binary Tree.py) [Java]()|Easy|| -|105|[Construct Binary Tree from Preorder and Inorder Traversal](https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal)|[Python](./python/105 Construct Binary Tree from Preorder and Inorder Traversal.py) [Java]()|Medium|| -|106|[Construct Binary Tree from Inorder and Postorder Traversal](https://leetcode.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal)|[Python](./python/106 Construct Binary Tree from Inorder and Postorder Traversal.py) [Java]()|Medium|| -|108|[Convert Sorted Array to Binary Search Tree](https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree)|[Python](./python/108 Convert Sorted Array to Binary Search Tree.py) [Java]()|Easy|| -|109|[Convert Sorted List to Binary Search Tree](https://leetcode.com/problems/convert-sorted-list-to-binary-search-tree)|[Python](./python/109 Convert Sorted List to Binary Search Tree.py) [Java]()|Medium|| -|110|[Balanced Binary Tree](https://leetcode.com/problems/balanced-binary-tree)|[Python](./python/110 Balanced Binary Tree.py) [Java]()|Easy|| -|111|[Minimum Depth of Binary Tree](https://leetcode.com/problems/minimum-depth-of-binary-tree)|[Python](./python/111 Minimum Depth of Binary Tree.py) [Java]()|Easy|| -|112|[Path Sum](https://leetcode.com/problems/path-sum)|[Python](./python/112 Path Sum.py) [Java]()|Easy|| -|113|[Path Sum II](https://leetcode.com/problems/path-sum-ii)|[Python](./python/113 Path Sum II.py) [Java]()|Medium|| -|114|[Flatten Binary Tree to Linked List](https://leetcode.com/problems/flatten-binary-tree-to-linked-list)|[Python](./python/114 Flatten Binary Tree to Linked List.py) [Java]()|Medium|| -|116|[Populating Next Right Pointers in Each Node](https://leetcode.com/problems/populating-next-right-pointers-in-each-node)|[Python](./python/116 Populating Next Right Pointers in Each Node.py) [Java]()|Medium|| -|117|[Populating Next Right Pointers in Each Node II](https://leetcode.com/problems/populating-next-right-pointers-in-each-node-ii)|[Python](./python/117 Populating Next Right Pointers in Each Node II.py) [Java]()|Medium|| -|124|[Binary Tree Maximum Path Sum](https://leetcode.com/problems/binary-tree-maximum-path-sum)|[Python](./python/124 Binary Tree Maximum Path Sum.py) [Java]()|Hard|| -|129|[Sum Root to Leaf Numbers](https://leetcode.com/problems/sum-root-to-leaf-numbers)|[Python](./python/129 Sum Root to Leaf Numbers.py) [Java]()|Medium|| -|133|[Clone Graph](https://leetcode.com/problems/clone-graph)|[Python](./python/133 Clone Graph.py) [Java]()|Medium|| -|199|[Binary Tree Right Side View](https://leetcode.com/problems/binary-tree-right-side-view)|[Python](./python/199 Binary Tree Right Side View.py) [Java]()|Medium|| -|200|[Number of Islands](https://leetcode.com/problems/number-of-islands)|[Python](./python/200 Number of Islands.py) [Java]()|Medium|| -|207|[Course Schedule](https://leetcode.com/problems/course-schedule)|[Python](./python/207 Course Schedule.py) [Java]()|Medium|| -|210|[Course Schedule II](https://leetcode.com/problems/course-schedule-ii)|[Python](./python/210 Course Schedule II.py) [Java]()|Medium|| -|257|[Binary Tree Paths](https://leetcode.com/problems/binary-tree-paths)|[Python](./python/257 Binary Tree Paths.py) [Java]()|Easy|| -|261|[Graph Valid Tree](https://leetcode.com/problems/graph-valid-tree)|[Python](./python/261 Graph Valid Tree.py) [Java]()|Medium|| -|301|[Remove Invalid Parentheses](https://leetcode.com/problems/remove-invalid-parentheses)|[Python](./python/301 Remove Invalid Parentheses.py) [Java]()|Hard|| -|323|[Number of Connected Components in an Undirected Graph](https://leetcode.com/problems/number-of-connected-components-in-an-undirected-graph)|[Python](./python/323 Number of Connected Components in an Undirected Graph.py) [Java]()|Medium|| -|329|[Longest Increasing Path in a Matrix](https://leetcode.com/problems/longest-increasing-path-in-a-matrix)|[Python](./python/329 Longest Increasing Path in a Matrix.py) [Java]()|Hard|| -|332|[Reconstruct Itinerary](https://leetcode.com/problems/reconstruct-itinerary)|[Python](./python/332 Reconstruct Itinerary.py) [Java]()|Medium|| -|337|[House Robber III](https://leetcode.com/problems/house-robber-iii)|[Python](./python/337 House Robber III.py) [Java]()|Medium|| -|339|[Nested List Weight Sum](https://leetcode.com/problems/nested-list-weight-sum)|[Python](./python/339 Nested List Weight Sum.py) [Java]()|Easy|| -|364|[Nested List Weight Sum II](https://leetcode.com/problems/nested-list-weight-sum-ii)|[Python](./python/364 Nested List Weight Sum II.py) [Java]()|Medium|| -|366|[Find Leaves of Binary Tree](https://leetcode.com/problems/find-leaves-of-binary-tree)|[Python](./python/366 Find Leaves of Binary Tree.py) [Java]()|Medium|| -|394|[Decode String](https://leetcode.com/problems/decode-string)|[Python](./python/394 Decode String.py) [Java]()|Medium|| -|417|[Pacific Atlantic Water Flow](https://leetcode.com/problems/pacific-atlantic-water-flow)|[Python](./python/417 Pacific Atlantic Water Flow.py) [Java]()|Medium|| -|439|[Ternary Expression Parser](https://leetcode.com/problems/ternary-expression-parser)|[Python](./python/439 Ternary Expression Parser.py) [Java]()|Medium|| -|472|[Concatenated Words](https://leetcode.com/problems/concatenated-words)|[Python](./python/472 Concatenated Words.py) [Java]()|Hard|| -|473|[Matchsticks to Square](https://leetcode.com/problems/matchsticks-to-square)|[Python](./python/473 Matchsticks to Square.py) [Java]()|Medium|| -|488|[Zuma Game](https://leetcode.com/problems/zuma-game)|[Python](./python/488 Zuma Game.py) [Java]()|Hard|| -|490|[The Maze](https://leetcode.com/problems/the-maze)|[Python](./python/490 The Maze.py) [Java]()|Medium|| -|491|[Increasing Subsequences](https://leetcode.com/problems/increasing-subsequences)|[Python](./python/491 Increasing Subsequences.py) [Java]()|Medium|| -|494|[Target Sum](https://leetcode.com/problems/target-sum)|[Python](./python/494 Target Sum.py) [Java]()|Medium|| -|499|[The Maze III](https://leetcode.com/problems/the-maze-iii)|[Python](./python/499 The Maze III.py) [Java]()|Hard|| -|505|[The Maze II](https://leetcode.com/problems/the-maze-ii)|[Python](./python/505 The Maze II.py) [Java]()|Medium|| -|513|[Find Bottom Left Tree Value](https://leetcode.com/problems/find-bottom-left-tree-value)|[Python](./python/513 Find Bottom Left Tree Value.py) [Java]()|Medium|| -|514|[Freedom Trail](https://leetcode.com/problems/freedom-trail)|[Python](./python/514 Freedom Trail.py) [Java]()|Hard|| -|515|[Find Largest Value in Each Tree Row](https://leetcode.com/problems/find-largest-value-in-each-tree-row)|[Python](./python/515 Find Largest Value in Each Tree Row.py) [Java]()|Medium|| -|529|[Minesweeper](https://leetcode.com/problems/minesweeper)|[Python](./python/529 Minesweeper.py) [Java]()|Medium|| -|531|[Lonely Pixel I](https://leetcode.com/problems/lonely-pixel-i)|[Python](./python/531 Lonely Pixel I.py) [Java]()|Medium|| -|533|[Lonely Pixel II](https://leetcode.com/problems/lonely-pixel-ii)|[Python](./python/533 Lonely Pixel II.py) [Java]()|Medium|| -|542|[01 Matrix](https://leetcode.com/problems/01-matrix)|[Python](./python/542 01 Matrix.py) [Java]()|Medium|| -|546|[Remove Boxes](https://leetcode.com/problems/remove-boxes)|[Python](./python/546 Remove Boxes.py) [Java]()|Hard|| -|547|[Friend Circles](https://leetcode.com/problems/friend-circles)|[Python](./python/547 Friend Circles.py) [Java]()|Medium|| +|98|[Validate Binary Search Tree](https://leetcode.com/problems/validate-binary-search-tree)| [Python](./python/098%20Validate%20Binary%20Search%20Tree.py) [Java]() |Medium|| +|99|[Recover Binary Search Tree](https://leetcode.com/problems/recover-binary-search-tree)| [Python](./python/099%20Recover%20Binary%20Search%20Tree.py) [Java]() |Hard|| +|100|[Same Tree](https://leetcode.com/problems/same-tree)| [Python](./python/100%20Same%20Tree.py) [Java]() |Easy|| +|101|[Symmetric Tree](https://leetcode.com/problems/symmetric-tree)| [Python](./python/101%20Symmetric%20Tree.py) [Java]() |Easy|| +|104|[Maximum Depth of Binary Tree](https://leetcode.com/problems/maximum-depth-of-binary-tree)| [Python](./python/104%20Maximum%20Depth%20of%20Binary%20Tree.py) [Java]() |Easy|| +|105|[Construct Binary Tree from Preorder and Inorder Traversal](https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal)| [Python](./python/105%20Construct%20Binary%20Tree%20from%20Preorder%20and%20Inorder%20Traversal.py) [Java]() |Medium|| +|106|[Construct Binary Tree from Inorder and Postorder Traversal](https://leetcode.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal)| [Python](./python/106%20Construct%20Binary%20Tree%20from%20Inorder%20and%20Postorder%20Traversal.py) [Java]() |Medium|| +|108|[Convert Sorted Array to Binary Search Tree](https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree)| [Python](./python/108%20Convert%20Sorted%20Array%20to%20Binary%20Search%20Tree.py) [Java]() |Easy|| +|109|[Convert Sorted List to Binary Search Tree](https://leetcode.com/problems/convert-sorted-list-to-binary-search-tree)| [Python](./python/109%20Convert%20Sorted%20List%20to%20Binary%20Search%20Tree.py) [Java]() |Medium|| +|110|[Balanced Binary Tree](https://leetcode.com/problems/balanced-binary-tree)| [Python](./python/110%20Balanced%20Binary%20Tree.py) [Java]() |Easy|| +|111|[Minimum Depth of Binary Tree](https://leetcode.com/problems/minimum-depth-of-binary-tree)| [Python](./python/111%20Minimum%20Depth%20of%20Binary%20Tree.py) [Java]() |Easy|| +|112|[Path Sum](https://leetcode.com/problems/path-sum)| [Python](./python/112%20Path%20Sum.py) [Java]() |Easy|| +|113|[Path Sum II](https://leetcode.com/problems/path-sum-ii)| [Python](./python/113%20Path%20Sum%20II.py) [Java]() |Medium|| +|114|[Flatten Binary Tree to Linked List](https://leetcode.com/problems/flatten-binary-tree-to-linked-list)| [Python](./python/114%20Flatten%20Binary%20Tree%20to%20Linked%20List.py) [Java]() |Medium|| +|116|[Populating Next Right Pointers in Each Node](https://leetcode.com/problems/populating-next-right-pointers-in-each-node)| [Python](./python/116%20Populating%20Next%20Right%20Pointers%20in%20Each%20Node.py) [Java]() |Medium|| +|117|[Populating Next Right Pointers in Each Node II](https://leetcode.com/problems/populating-next-right-pointers-in-each-node-ii)| [Python](./python/117%20Populating%20Next%20Right%20Pointers%20in%20Each%20Node%20II.py) [Java]() |Medium|| +|124|[Binary Tree Maximum Path Sum](https://leetcode.com/problems/binary-tree-maximum-path-sum)| [Python](./python/124%20Binary%20Tree%20Maximum%20Path%20Sum.py) [Java]() |Hard|| +|129|[Sum Root to Leaf Numbers](https://leetcode.com/problems/sum-root-to-leaf-numbers)| [Python](./python/129%20Sum%20Root%20to%20Leaf%20Numbers.py) [Java]() |Medium|| +|133|[Clone Graph](https://leetcode.com/problems/clone-graph)| [Python](./python/133%20Clone%20Graph.py) [Java]() |Medium|| +|199|[Binary Tree Right Side View](https://leetcode.com/problems/binary-tree-right-side-view)| [Python](./python/199%20Binary%20Tree%20Right%20Side%20View.py) [Java]() |Medium|| +|200|[Number of Islands](https://leetcode.com/problems/number-of-islands)| [Python](./python/200%20Number%20of%20Islands.py) [Java]() |Medium|| +|207|[Course Schedule](https://leetcode.com/problems/course-schedule)| [Python](./python/207%20Course%20Schedule.py) [Java]() |Medium|| +|210|[Course Schedule II](https://leetcode.com/problems/course-schedule-ii)| [Python](./python/210%20Course%20Schedule%20II.py) [Java]() |Medium|| +|257|[Binary Tree Paths](https://leetcode.com/problems/binary-tree-paths)| [Python](./python/257%20Binary%20Tree%20Paths.py) [Java]() |Easy|| +|261|[Graph Valid Tree](https://leetcode.com/problems/graph-valid-tree)| [Python](./python/261%20Graph%20Valid%20Tree.py) [Java]() |Medium|| +|301|[Remove Invalid Parentheses](https://leetcode.com/problems/remove-invalid-parentheses)| [Python](./python/301%20Remove%20Invalid%20Parentheses.py) [Java]() |Hard|| +|323|[Number of Connected Components in an Undirected Graph](https://leetcode.com/problems/number-of-connected-components-in-an-undirected-graph)| [Python](./python/323%20Number%20of%20Connected%20Components%20in%20an%20Undirected%20Graph.py) [Java]() |Medium|| +|329|[Longest Increasing Path in a Matrix](https://leetcode.com/problems/longest-increasing-path-in-a-matrix)| [Python](./python/329%20Longest%20Increasing%20Path%20in%20a%20Matrix.py) [Java]() |Hard|| +|332|[Reconstruct Itinerary](https://leetcode.com/problems/reconstruct-itinerary)| [Python](./python/332%20Reconstruct%20Itinerary.py) [Java]() |Medium|| +|337|[House Robber III](https://leetcode.com/problems/house-robber-iii)| [Python](./python/337%20House%20Robber%20III.py) [Java]() |Medium|| +|339|[Nested List Weight Sum](https://leetcode.com/problems/nested-list-weight-sum)| [Python](./python/339%20Nested%20List%20Weight%20Sum.py) [Java]() |Easy|| +|364|[Nested List Weight Sum II](https://leetcode.com/problems/nested-list-weight-sum-ii)| [Python](./python/364%20Nested%20List%20Weight%20Sum%20II.py) [Java]() |Medium|| +|366|[Find Leaves of Binary Tree](https://leetcode.com/problems/find-leaves-of-binary-tree)| [Python](./python/366%20Find%20Leaves%20of%20Binary%20Tree.py) [Java]() |Medium|| +|394|[Decode String](https://leetcode.com/problems/decode-string)| [Python](./python/394%20Decode%20String.py) [Java]() |Medium|| +|417|[Pacific Atlantic Water Flow](https://leetcode.com/problems/pacific-atlantic-water-flow)| [Python](./python/417%20Pacific%20Atlantic%20Water%20Flow.py) [Java]() |Medium|| +|439|[Ternary Expression Parser](https://leetcode.com/problems/ternary-expression-parser)| [Python](./python/439%20Ternary%20Expression%20Parser.py) [Java]() |Medium|| +|472|[Concatenated Words](https://leetcode.com/problems/concatenated-words)| [Python](./python/472%20Concatenated%20Words.py) [Java]() |Hard|| +|473|[Matchsticks to Square](https://leetcode.com/problems/matchsticks-to-square)| [Python](./python/473%20Matchsticks%20to%20Square.py) [Java]() |Medium|| +|488|[Zuma Game](https://leetcode.com/problems/zuma-game)| [Python](./python/488%20Zuma%20Game.py) [Java]() |Hard|| +|490|[The Maze](https://leetcode.com/problems/the-maze)| [Python](./python/490%20The%20Maze.py) [Java]() |Medium|| +|491|[Increasing Subsequences](https://leetcode.com/problems/increasing-subsequences)| [Python](./python/491%20Increasing%20Subsequences.py) [Java]() |Medium|| +|494|[Target Sum](https://leetcode.com/problems/target-sum)| [Python](./python/494%20Target%20Sum.py) [Java]() |Medium|| +|499|[The Maze III](https://leetcode.com/problems/the-maze-iii)| [Python](./python/499%20The%20Maze%20III.py) [Java]() |Hard|| +|505|[The Maze II](https://leetcode.com/problems/the-maze-ii)| [Python](./python/505%20The%20Maze%20II.py) [Java]() |Medium|| +|513|[Find Bottom Left Tree Value](https://leetcode.com/problems/find-bottom-left-tree-value)| [Python](./python/513%20Find%20Bottom%20Left%20Tree%20Value.py) [Java]() |Medium|| +|514|[Freedom Trail](https://leetcode.com/problems/freedom-trail)| [Python](./python/514%20Freedom%20Trail.py) [Java]() |Hard|| +|515|[Find Largest Value in Each Tree Row](https://leetcode.com/problems/find-largest-value-in-each-tree-row)| [Python](./python/515%20Find%20Largest%20Value%20in%20Each%20Tree%20Row.py) [Java]() |Medium|| +|529|[Minesweeper](https://leetcode.com/problems/minesweeper)| [Python](./python/529%20Minesweeper.py) [Java]() |Medium|| +|531|[Lonely Pixel I](https://leetcode.com/problems/lonely-pixel-i)| [Python](./python/531%20Lonely%20Pixel%20I.py) [Java]() |Medium|| +|533|[Lonely Pixel II](https://leetcode.com/problems/lonely-pixel-ii)| [Python](./python/533%20Lonely%20Pixel%20II.py) [Java]() |Medium|| +|542|[01 Matrix](https://leetcode.com/problems/01-matrix)| [Python](./python/542%2001%20Matrix.py) [Java]() |Medium|| +|546|[Remove Boxes](https://leetcode.com/problems/remove-boxes)| [Python](./python/546%20Remove%20Boxes.py) [Java]() |Hard|| +|547|[Friend Circles](https://leetcode.com/problems/friend-circles)| [Python](./python/547%20Friend%20Circles.py) [Java]() |Medium|| ## Breadth-first Search | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|101|[Symmetric Tree](https://leetcode.com/problems/symmetric-tree)|[Python](./python/101 Symmetric Tree.py) [Java]()|Easy|| -|102|[Binary Tree Level Order Traversal](https://leetcode.com/problems/binary-tree-level-order-traversal)|[Python](./python/102 Binary Tree Level Order Traversal.py) [Java]()|Medium|| -|103|[Binary Tree Zigzag Level Order Traversal](https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal)|[Python](./python/103 Binary Tree Zigzag Level Order Traversal.py) [Java]()|Medium|| -|107|[Binary Tree Level Order Traversal II](https://leetcode.com/problems/binary-tree-level-order-traversal-ii)|[Python](./python/107 Binary Tree Level Order Traversal II.py) [Java]()|Easy|| -|111|[Minimum Depth of Binary Tree](https://leetcode.com/problems/minimum-depth-of-binary-tree)|[Python](./python/111 Minimum Depth of Binary Tree.py) [Java]()|Easy|| -|126|[Word Ladder II](https://leetcode.com/problems/word-ladder-ii)|[Python](./python/126 Word Ladder II.py) [Java]()|Hard|| -|130|[Surrounded Regions](https://leetcode.com/problems/surrounded-regions)|[Python](./python/130 Surrounded Regions.py) [Java]()|Medium|| -|133|[Clone Graph](https://leetcode.com/problems/clone-graph)|[Python](./python/133 Clone Graph.py) [Java]()|Medium|| -|199|[Binary Tree Right Side View](https://leetcode.com/problems/binary-tree-right-side-view)|[Python](./python/199 Binary Tree Right Side View.py) [Java]()|Medium|| -|200|[Number of Islands](https://leetcode.com/problems/number-of-islands)|[Python](./python/200 Number of Islands.py) [Java]()|Medium|| -|207|[Course Schedule](https://leetcode.com/problems/course-schedule)|[Python](./python/207 Course Schedule.py) [Java]()|Medium|| -|210|[Course Schedule II](https://leetcode.com/problems/course-schedule-ii)|[Python](./python/210 Course Schedule II.py) [Java]()|Medium|| -|261|[Graph Valid Tree](https://leetcode.com/problems/graph-valid-tree)|[Python](./python/261 Graph Valid Tree.py) [Java]()|Medium|| -|279|[Perfect Squares](https://leetcode.com/problems/perfect-squares)|[Python](./python/279 Perfect Squares.py) [Java]()|Medium|| -|286|[Walls and Gates](https://leetcode.com/problems/walls-and-gates)|[Python](./python/286 Walls and Gates.py) [Java]()|Medium|| -|301|[Remove Invalid Parentheses](https://leetcode.com/problems/remove-invalid-parentheses)|[Python](./python/301 Remove Invalid Parentheses.py) [Java]()|Hard|| -|310|[Minimum Height Trees](https://leetcode.com/problems/minimum-height-trees)|[Python](./python/310 Minimum Height Trees.py) [Java]()|Medium|| -|317|[Shortest Distance from All Buildings](https://leetcode.com/problems/shortest-distance-from-all-buildings)|[Python](./python/317 Shortest Distance from All Buildings.py) [Java]()|Hard|| -|323|[Number of Connected Components in an Undirected Graph](https://leetcode.com/problems/number-of-connected-components-in-an-undirected-graph)|[Python](./python/323 Number of Connected Components in an Undirected Graph.py) [Java]()|Medium|| -|407|[Trapping Rain Water II](https://leetcode.com/problems/trapping-rain-water-ii)|[Python](./python/407 Trapping Rain Water II.py) [Java]()|Hard|| -|417|[Pacific Atlantic Water Flow](https://leetcode.com/problems/pacific-atlantic-water-flow)|[Python](./python/417 Pacific Atlantic Water Flow.py) [Java]()|Medium|| -|490|[The Maze](https://leetcode.com/problems/the-maze)|[Python](./python/490 The Maze.py) [Java]()|Medium|| -|499|[The Maze III](https://leetcode.com/problems/the-maze-iii)|[Python](./python/499 The Maze III.py) [Java]()|Hard|| -|505|[The Maze II](https://leetcode.com/problems/the-maze-ii)|[Python](./python/505 The Maze II.py) [Java]()|Medium|| -|513|[Find Bottom Left Tree Value](https://leetcode.com/problems/find-bottom-left-tree-value)|[Python](./python/513 Find Bottom Left Tree Value.py) [Java]()|Medium|| -|515|[Find Largest Value in Each Tree Row](https://leetcode.com/problems/find-largest-value-in-each-tree-row)|[Python](./python/515 Find Largest Value in Each Tree Row.py) [Java]()|Medium|| -|529|[Minesweeper](https://leetcode.com/problems/minesweeper)|[Python](./python/529 Minesweeper.py) [Java]()|Medium|| -|542|[01 Matrix](https://leetcode.com/problems/01-matrix)|[Python](./python/542 01 Matrix.py) [Java]()|Medium|| +|101|[Symmetric Tree](https://leetcode.com/problems/symmetric-tree)| [Python](./python/101%20Symmetric%20Tree.py) [Java]() |Easy|| +|102|[Binary Tree Level Order Traversal](https://leetcode.com/problems/binary-tree-level-order-traversal)| [Python](./python/102%20Binary%20Tree%20Level%20Order%20Traversal.py) [Java]() |Medium|| +|103|[Binary Tree Zigzag Level Order Traversal](https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal)| [Python](./python/103%20Binary%20Tree%20Zigzag%20Level%20Order%20Traversal.py) [Java]() |Medium|| +|107|[Binary Tree Level Order Traversal II](https://leetcode.com/problems/binary-tree-level-order-traversal-ii)| [Python](./python/107%20Binary%20Tree%20Level%20Order%20Traversal%20II.py) [Java]() |Easy|| +|111|[Minimum Depth of Binary Tree](https://leetcode.com/problems/minimum-depth-of-binary-tree)| [Python](./python/111%20Minimum%20Depth%20of%20Binary%20Tree.py) [Java]() |Easy|| +|126|[Word Ladder II](https://leetcode.com/problems/word-ladder-ii)| [Python](./python/126%20Word%20Ladder%20II.py) [Java]() |Hard|| +|130|[Surrounded Regions](https://leetcode.com/problems/surrounded-regions)| [Python](./python/130%20Surrounded%20Regions.py) [Java]() |Medium|| +|133|[Clone Graph](https://leetcode.com/problems/clone-graph)| [Python](./python/133%20Clone%20Graph.py) [Java]() |Medium|| +|199|[Binary Tree Right Side View](https://leetcode.com/problems/binary-tree-right-side-view)| [Python](./python/199%20Binary%20Tree%20Right%20Side%20View.py) [Java]() |Medium|| +|200|[Number of Islands](https://leetcode.com/problems/number-of-islands)| [Python](./python/200%20Number%20of%20Islands.py) [Java]() |Medium|| +|207|[Course Schedule](https://leetcode.com/problems/course-schedule)| [Python](./python/207%20Course%20Schedule.py) [Java]() |Medium|| +|210|[Course Schedule II](https://leetcode.com/problems/course-schedule-ii)| [Python](./python/210%20Course%20Schedule%20II.py) [Java]() |Medium|| +|261|[Graph Valid Tree](https://leetcode.com/problems/graph-valid-tree)| [Python](./python/261%20Graph%20Valid%20Tree.py) [Java]() |Medium|| +|279|[Perfect Squares](https://leetcode.com/problems/perfect-squares)| [Python](./python/279%20Perfect%20Squares.py) [Java]() |Medium|| +|286|[Walls and Gates](https://leetcode.com/problems/walls-and-gates)| [Python](./python/286%20Walls%20and%20Gates.py) [Java]() |Medium|| +|301|[Remove Invalid Parentheses](https://leetcode.com/problems/remove-invalid-parentheses)| [Python](./python/301%20Remove%20Invalid%20Parentheses.py) [Java]() |Hard|| +|310|[Minimum Height Trees](https://leetcode.com/problems/minimum-height-trees)| [Python](./python/310%20Minimum%20Height%20Trees.py) [Java]() |Medium|| +|317|[Shortest Distance from All Buildings](https://leetcode.com/problems/shortest-distance-from-all-buildings)| [Python](./python/317%20Shortest%20Distance%20from%20All%20Buildings.py) [Java]() |Hard|| +|323|[Number of Connected Components in an Undirected Graph](https://leetcode.com/problems/number-of-connected-components-in-an-undirected-graph)| [Python](./python/323%20Number%20of%20Connected%20Components%20in%20an%20Undirected%20Graph.py) [Java]() |Medium|| +|407|[Trapping Rain Water II](https://leetcode.com/problems/trapping-rain-water-ii)| [Python](./python/407%20Trapping%20Rain%20Water%20II.py) [Java]() |Hard|| +|417|[Pacific Atlantic Water Flow](https://leetcode.com/problems/pacific-atlantic-water-flow)| [Python](./python/417%20Pacific%20Atlantic%20Water%20Flow.py) [Java]() |Medium|| +|490|[The Maze](https://leetcode.com/problems/the-maze)| [Python](./python/490%20The%20Maze.py) [Java]() |Medium|| +|499|[The Maze III](https://leetcode.com/problems/the-maze-iii)| [Python](./python/499%20The%20Maze%20III.py) [Java]() |Hard|| +|505|[The Maze II](https://leetcode.com/problems/the-maze-ii)| [Python](./python/505%20The%20Maze%20II.py) [Java]() |Medium|| +|513|[Find Bottom Left Tree Value](https://leetcode.com/problems/find-bottom-left-tree-value)| [Python](./python/513%20Find%20Bottom%20Left%20Tree%20Value.py) [Java]() |Medium|| +|515|[Find Largest Value in Each Tree Row](https://leetcode.com/problems/find-largest-value-in-each-tree-row)| [Python](./python/515%20Find%20Largest%20Value%20in%20Each%20Tree%20Row.py) [Java]() |Medium|| +|529|[Minesweeper](https://leetcode.com/problems/minesweeper)| [Python](./python/529%20Minesweeper.py) [Java]() |Medium|| +|542|[01 Matrix](https://leetcode.com/problems/01-matrix)| [Python](./python/542%2001%20Matrix.py) [Java]() |Medium|| ## Union Find | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|128|[Longest Consecutive Sequence](https://leetcode.com/problems/longest-consecutive-sequence)|[Python](./python/128 Longest Consecutive Sequence.py) [Java]()|Hard|| -|130|[Surrounded Regions](https://leetcode.com/problems/surrounded-regions)|[Python](./python/130 Surrounded Regions.py) [Java]()|Medium|| -|200|[Number of Islands](https://leetcode.com/problems/number-of-islands)|[Python](./python/200 Number of Islands.py) [Java]()|Medium|| -|261|[Graph Valid Tree](https://leetcode.com/problems/graph-valid-tree)|[Python](./python/261 Graph Valid Tree.py) [Java]()|Medium|| -|305|[Number of Islands II](https://leetcode.com/problems/number-of-islands-ii)|[Python](./python/305 Number of Islands II.py) [Java]()|Hard|| -|323|[Number of Connected Components in an Undirected Graph](https://leetcode.com/problems/number-of-connected-components-in-an-undirected-graph)|[Python](./python/323 Number of Connected Components in an Undirected Graph.py) [Java]()|Medium|| -|547|[Friend Circles](https://leetcode.com/problems/friend-circles)|[Python](./python/547 Friend Circles.py) [Java]()|Medium|| +|128|[Longest Consecutive Sequence](https://leetcode.com/problems/longest-consecutive-sequence)| [Python](./python/128%20Longest%20Consecutive%20Sequence.py) [Java]() |Hard|| +|130|[Surrounded Regions](https://leetcode.com/problems/surrounded-regions)| [Python](./python/130%20Surrounded%20Regions.py) [Java]() |Medium|| +|200|[Number of Islands](https://leetcode.com/problems/number-of-islands)| [Python](./python/200%20Number%20of%20Islands.py) [Java]() |Medium|| +|261|[Graph Valid Tree](https://leetcode.com/problems/graph-valid-tree)| [Python](./python/261%20Graph%20Valid%20Tree.py) [Java]() |Medium|| +|305|[Number of Islands II](https://leetcode.com/problems/number-of-islands-ii)| [Python](./python/305%20Number%20of%20Islands%20II.py) [Java]() |Hard|| +|323|[Number of Connected Components in an Undirected Graph](https://leetcode.com/problems/number-of-connected-components-in-an-undirected-graph)| [Python](./python/323%20Number%20of%20Connected%20Components%20in%20an%20Undirected%20Graph.py) [Java]() |Medium|| +|547|[Friend Circles](https://leetcode.com/problems/friend-circles)| [Python](./python/547%20Friend%20Circles.py) [Java]() |Medium|| ## Graph | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|133|[Clone Graph](https://leetcode.com/problems/clone-graph)|[Python](./python/133 Clone Graph.py) [Java]()|Medium|| -|207|[Course Schedule](https://leetcode.com/problems/course-schedule)|[Python](./python/207 Course Schedule.py) [Java]()|Medium|| -|210|[Course Schedule II](https://leetcode.com/problems/course-schedule-ii)|[Python](./python/210 Course Schedule II.py) [Java]()|Medium|| -|261|[Graph Valid Tree](https://leetcode.com/problems/graph-valid-tree)|[Python](./python/261 Graph Valid Tree.py) [Java]()|Medium|| -|269|[Alien Dictionary](https://leetcode.com/problems/alien-dictionary)|[Python](./python/269 Alien Dictionary.py) [Java]()|Hard|| -|310|[Minimum Height Trees](https://leetcode.com/problems/minimum-height-trees)|[Python](./python/310 Minimum Height Trees.py) [Java]()|Medium|| -|323|[Number of Connected Components in an Undirected Graph](https://leetcode.com/problems/number-of-connected-components-in-an-undirected-graph)|[Python](./python/323 Number of Connected Components in an Undirected Graph.py) [Java]()|Medium|| -|332|[Reconstruct Itinerary](https://leetcode.com/problems/reconstruct-itinerary)|[Python](./python/332 Reconstruct Itinerary.py) [Java]()|Medium|| -|399|[Evaluate Division](https://leetcode.com/problems/evaluate-division)|[Python](./python/399 Evaluate Division.py) [Java]()|Medium|| -|444|[Sequence Reconstruction](https://leetcode.com/problems/sequence-reconstruction)|[Python](./python/444 Sequence Reconstruction.py) [Java]()|Medium|| +|133|[Clone Graph](https://leetcode.com/problems/clone-graph)| [Python](./python/133%20Clone%20Graph.py) [Java]() |Medium|| +|207|[Course Schedule](https://leetcode.com/problems/course-schedule)| [Python](./python/207%20Course%20Schedule.py) [Java]() |Medium|| +|210|[Course Schedule II](https://leetcode.com/problems/course-schedule-ii)| [Python](./python/210%20Course%20Schedule%20II.py) [Java]() |Medium|| +|261|[Graph Valid Tree](https://leetcode.com/problems/graph-valid-tree)| [Python](./python/261%20Graph%20Valid%20Tree.py) [Java]() |Medium|| +|269|[Alien Dictionary](https://leetcode.com/problems/alien-dictionary)| [Python](./python/269%20Alien%20Dictionary.py) [Java]() |Hard|| +|310|[Minimum Height Trees](https://leetcode.com/problems/minimum-height-trees)| [Python](./python/310%20Minimum%20Height%20Trees.py) [Java]() |Medium|| +|323|[Number of Connected Components in an Undirected Graph](https://leetcode.com/problems/number-of-connected-components-in-an-undirected-graph)| [Python](./python/323%20Number%20of%20Connected%20Components%20in%20an%20Undirected%20Graph.py) [Java]() |Medium|| +|332|[Reconstruct Itinerary](https://leetcode.com/problems/reconstruct-itinerary)| [Python](./python/332%20Reconstruct%20Itinerary.py) [Java]() |Medium|| +|399|[Evaluate Division](https://leetcode.com/problems/evaluate-division)| [Python](./python/399%20Evaluate%20Division.py) [Java]() |Medium|| +|444|[Sequence Reconstruction](https://leetcode.com/problems/sequence-reconstruction)| [Python](./python/444%20Sequence%20Reconstruction.py) [Java]() |Medium|| ## Design | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|146|[LRU Cache](https://leetcode.com/problems/lru-cache)|[Python](./python/146 LRU Cache.py) [Java]()|Hard|| -|155|[Min Stack](https://leetcode.com/problems/min-stack)|[Python](./python/155 Min Stack.py) [Java]()|Easy|| -|170|[Two Sum III - Data structure design](https://leetcode.com/problems/two-sum-iii---data-structure-design)|[Python](./python/170 Two Sum III - Data structure design.py) [Java]()|Easy|| -|173|[Binary Search Tree Iterator](https://leetcode.com/problems/binary-search-tree-iterator)|[Python](./python/173 Binary Search Tree Iterator.py) [Java]()|Medium|| -|208|[Implement Trie (Prefix Tree)](https://leetcode.com/problems/implement-trie-(prefix-tree))|[Python](./python/208 Implement Trie (Prefix Tree).py) [Java]()|Medium|| -|211|[Add and Search Word - Data structure design](https://leetcode.com/problems/add-and-search-word---data-structure-design)|[Python](./python/211 Add and Search Word - Data structure design.py) [Java]()|Medium|| -|225|[Implement Stack using Queues](https://leetcode.com/problems/implement-stack-using-queues)|[Python](./python/225 Implement Stack using Queues.py) [Java]()|Easy|| -|232|[Implement Queue using Stacks](https://leetcode.com/problems/implement-queue-using-stacks)|[Python](./python/232 Implement Queue using Stacks.py) [Java]()|Easy|| -|244|[Shortest Word Distance II](https://leetcode.com/problems/shortest-word-distance-ii)|[Python](./python/244 Shortest Word Distance II.py) [Java]()|Medium|| -|251|[Flatten 2D Vector](https://leetcode.com/problems/flatten-2d-vector)|[Python](./python/251 Flatten 2D Vector.py) [Java]()|Medium|| -|281|[Zigzag Iterator](https://leetcode.com/problems/zigzag-iterator)|[Python](./python/281 Zigzag Iterator.py) [Java]()|Medium|| -|284|[Peeking Iterator](https://leetcode.com/problems/peeking-iterator)|[Python](./python/284 Peeking Iterator.py) [Java]()|Medium|| -|288|[Unique Word Abbreviation](https://leetcode.com/problems/unique-word-abbreviation)|[Python](./python/288 Unique Word Abbreviation.py) [Java]()|Medium|| -|295|[Find Median from Data Stream](https://leetcode.com/problems/find-median-from-data-stream)|[Python](./python/295 Find Median from Data Stream.py) [Java]()|Hard|| -|297|[Serialize and Deserialize Binary Tree](https://leetcode.com/problems/serialize-and-deserialize-binary-tree)|[Python](./python/297 Serialize and Deserialize Binary Tree.py) [Java]()|Hard|| -|341|[Flatten Nested List Iterator](https://leetcode.com/problems/flatten-nested-list-iterator)|[Python](./python/341 Flatten Nested List Iterator.py) [Java]()|Medium|| -|346|[Moving Average from Data Stream](https://leetcode.com/problems/moving-average-from-data-stream)|[Python](./python/346 Moving Average from Data Stream.py) [Java]()|Easy|| -|348|[Design Tic-Tac-Toe](https://leetcode.com/problems/design-tic-tac-toe)|[Python](./python/348 Design Tic-Tac-Toe.py) [Java]()|Medium|| -|353|[Design Snake Game](https://leetcode.com/problems/design-snake-game)|[Python](./python/353 Design Snake Game.py) [Java]()|Medium|| -|355|[Design Twitter](https://leetcode.com/problems/design-twitter)|[Python](./python/355 Design Twitter.py) [Java]()|Medium|| -|359|[Logger Rate Limiter](https://leetcode.com/problems/logger-rate-limiter)|[Python](./python/359 Logger Rate Limiter.py) [Java]()|Easy|| -|362|[Design Hit Counter](https://leetcode.com/problems/design-hit-counter)|[Python](./python/362 Design Hit Counter.py) [Java]()|Medium|| -|379|[Design Phone Directory](https://leetcode.com/problems/design-phone-directory)|[Python](./python/379 Design Phone Directory.py) [Java]()|Medium|| -|380|[Insert Delete GetRandom O(1)](https://leetcode.com/problems/insert-delete-getrandom-o(1))|[Python](./python/380 Insert Delete GetRandom O(1).py) [Java]()|Medium|| -|381|[Insert Delete GetRandom O(1) - Duplicates allowed](https://leetcode.com/problems/insert-delete-getrandom-o(1)---duplicates-allowed)|[Python](./python/381 Insert Delete GetRandom O(1) - Duplicates allowed.py) [Java]()|Hard|| -|432|[All O`one Data Structure](https://leetcode.com/problems/all-o`one-data-structure)|[Python](./python/432 All O`one Data Structure.py) [Java]()|Hard|| -|460|[LFU Cache](https://leetcode.com/problems/lfu-cache)|[Python](./python/460 LFU Cache.py) [Java]()|Hard|| +|146|[LRU Cache](https://leetcode.com/problems/lru-cache)| [Python](./python/146%20LRU%20Cache.py) [Java]() |Hard|| +|155|[Min Stack](https://leetcode.com/problems/min-stack)| [Python](./python/155%20Min%20Stack.py) [Java]() |Easy|| +|170|[Two Sum III - Data structure design](https://leetcode.com/problems/two-sum-iii---data-structure-design)| [Python](./python/170%20Two%20Sum%20III%20-%20Data%20structure%20design.py) [Java]() |Easy|| +|173|[Binary Search Tree Iterator](https://leetcode.com/problems/binary-search-tree-iterator)| [Python](./python/173%20Binary%20Search%20Tree%20Iterator.py) [Java]() |Medium|| +|208|[Implement Trie (Prefix Tree)](https://leetcode.com/problems/implement-trie-(prefix-tree))| [Python](./python/208%20Implement%20Trie%20(Prefix%20Tree).py) [Java]() |Medium|| +|211|[Add and Search Word - Data structure design](https://leetcode.com/problems/add-and-search-word---data-structure-design)| [Python](./python/211%20Add%20and%20Search%20Word%20-%20Data%20structure%20design.py) [Java]() |Medium|| +|225|[Implement Stack using Queues](https://leetcode.com/problems/implement-stack-using-queues)| [Python](./python/225%20Implement%20Stack%20using%20Queues.py) [Java]() |Easy|| +|232|[Implement Queue using Stacks](https://leetcode.com/problems/implement-queue-using-stacks)| [Python](./python/232%20Implement%20Queue%20using%20Stacks.py) [Java]() |Easy|| +|244|[Shortest Word Distance II](https://leetcode.com/problems/shortest-word-distance-ii)| [Python](./python/244%20Shortest%20Word%20Distance%20II.py) [Java]() |Medium|| +|251|[Flatten 2D Vector](https://leetcode.com/problems/flatten-2d-vector)| [Python](./python/251%20Flatten%202D%20Vector.py) [Java]() |Medium|| +|281|[Zigzag Iterator](https://leetcode.com/problems/zigzag-iterator)| [Python](./python/281%20Zigzag%20Iterator.py) [Java]() |Medium|| +|284|[Peeking Iterator](https://leetcode.com/problems/peeking-iterator)| [Python](./python/284%20Peeking%20Iterator.py) [Java]() |Medium|| +|288|[Unique Word Abbreviation](https://leetcode.com/problems/unique-word-abbreviation)| [Python](./python/288%20Unique%20Word%20Abbreviation.py) [Java]() |Medium|| +|295|[Find Median from Data Stream](https://leetcode.com/problems/find-median-from-data-stream)| [Python](./python/295%20Find%20Median%20from%20Data%20Stream.py) [Java]() |Hard|| +|297|[Serialize and Deserialize Binary Tree](https://leetcode.com/problems/serialize-and-deserialize-binary-tree)| [Python](./python/297%20Serialize%20and%20Deserialize%20Binary%20Tree.py) [Java]() |Hard|| +|341|[Flatten Nested List Iterator](https://leetcode.com/problems/flatten-nested-list-iterator)| [Python](./python/341%20Flatten%20Nested%20List%20Iterator.py) [Java]() |Medium|| +|346|[Moving Average from Data Stream](https://leetcode.com/problems/moving-average-from-data-stream)| [Python](./python/346%20Moving%20Average%20from%20Data%20Stream.py) [Java]() |Easy|| +|348|[Design Tic-Tac-Toe](https://leetcode.com/problems/design-tic-tac-toe)| [Python](./python/348%20Design%20Tic-Tac-Toe.py) [Java]() |Medium|| +|353|[Design Snake Game](https://leetcode.com/problems/design-snake-game)| [Python](./python/353%20Design%20Snake%20Game.py) [Java]() |Medium|| +|355|[Design Twitter](https://leetcode.com/problems/design-twitter)| [Python](./python/355%20Design%20Twitter.py) [Java]() |Medium|| +|359|[Logger Rate Limiter](https://leetcode.com/problems/logger-rate-limiter)| [Python](./python/359%20Logger%20Rate%20Limiter.py) [Java]() |Easy|| +|362|[Design Hit Counter](https://leetcode.com/problems/design-hit-counter)| [Python](./python/362%20Design%20Hit%20Counter.py) [Java]() |Medium|| +|379|[Design Phone Directory](https://leetcode.com/problems/design-phone-directory)| [Python](./python/379%20Design%20Phone%20Directory.py) [Java]() |Medium|| +|380|[Insert Delete GetRandom O(1)](https://leetcode.com/problems/insert-delete-getrandom-o(1))| [Python](./python/380%20Insert%20Delete%20GetRandom%20O(1).py) [Java]() |Medium|| +|381|[Insert Delete GetRandom O(1) - Duplicates allowed](https://leetcode.com/problems/insert-delete-getrandom-o(1)---duplicates-allowed)| [Python](./python/381%20Insert%20Delete%20GetRandom%20O(1)%20-%20Duplicates%20allowed.py) [Java]() |Hard|| +|432|[All O`one Data Structure](https://leetcode.com/problems/all-o`one-data-structure)| [Python](./python/432%20All%20O`one%20Data%20Structure.py) [Java]() |Hard|| +|460|[LFU Cache](https://leetcode.com/problems/lfu-cache)| [Python](./python/460%20LFU%20Cache.py) [Java]() |Hard|| ## Topological Sort | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|207|[Course Schedule](https://leetcode.com/problems/course-schedule)|[Python](./python/207 Course Schedule.py) [Java]()|Medium|| -|210|[Course Schedule II](https://leetcode.com/problems/course-schedule-ii)|[Python](./python/210 Course Schedule II.py) [Java]()|Medium|| -|269|[Alien Dictionary](https://leetcode.com/problems/alien-dictionary)|[Python](./python/269 Alien Dictionary.py) [Java]()|Hard|| -|329|[Longest Increasing Path in a Matrix](https://leetcode.com/problems/longest-increasing-path-in-a-matrix)|[Python](./python/329 Longest Increasing Path in a Matrix.py) [Java]()|Hard|| -|444|[Sequence Reconstruction](https://leetcode.com/problems/sequence-reconstruction)|[Python](./python/444 Sequence Reconstruction.py) [Java]()|Medium|| +|207|[Course Schedule](https://leetcode.com/problems/course-schedule)| [Python](./python/207%20Course%20Schedule.py) [Java]() |Medium|| +|210|[Course Schedule II](https://leetcode.com/problems/course-schedule-ii)| [Python](./python/210%20Course%20Schedule%20II.py) [Java]() |Medium|| +|269|[Alien Dictionary](https://leetcode.com/problems/alien-dictionary)| [Python](./python/269%20Alien%20Dictionary.py) [Java]() |Hard|| +|329|[Longest Increasing Path in a Matrix](https://leetcode.com/problems/longest-increasing-path-in-a-matrix)| [Python](./python/329%20Longest%20Increasing%20Path%20in%20a%20Matrix.py) [Java]() |Hard|| +|444|[Sequence Reconstruction](https://leetcode.com/problems/sequence-reconstruction)| [Python](./python/444%20Sequence%20Reconstruction.py) [Java]() |Medium|| ## Trie | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|208|[Implement Trie (Prefix Tree)](https://leetcode.com/problems/implement-trie-(prefix-tree))|[Python](./python/208 Implement Trie (Prefix Tree).py) [Java]()|Medium|| -|211|[Add and Search Word - Data structure design](https://leetcode.com/problems/add-and-search-word---data-structure-design)|[Python](./python/211 Add and Search Word - Data structure design.py) [Java]()|Medium|| -|212|[Word Search II](https://leetcode.com/problems/word-search-ii)|[Python](./python/212 Word Search II.py) [Java]()|Hard|| -|336|[Palindrome Pairs](https://leetcode.com/problems/palindrome-pairs)|[Python](./python/336 Palindrome Pairs.py) [Java]()|Hard|| -|421|[Maximum XOR of Two Numbers in an Array](https://leetcode.com/problems/maximum-xor-of-two-numbers-in-an-array)|[Python](./python/421 Maximum XOR of Two Numbers in an Array.py) [Java]()|Medium|| -|425|[Word Squares](https://leetcode.com/problems/word-squares)|[Python](./python/425 Word Squares.py) [Java]()|Hard|| -|472|[Concatenated Words](https://leetcode.com/problems/concatenated-words)|[Python](./python/472 Concatenated Words.py) [Java]()|Hard|| +|208|[Implement Trie (Prefix Tree)](https://leetcode.com/problems/implement-trie-(prefix-tree))| [Python](./python/208%20Implement%20Trie%20(Prefix%20Tree).py) [Java]() |Medium|| +|211|[Add and Search Word - Data structure design](https://leetcode.com/problems/add-and-search-word---data-structure-design)| [Python](./python/211%20Add%20and%20Search%20Word%20-%20Data%20structure%20design.py) [Java]() |Medium|| +|212|[Word Search II](https://leetcode.com/problems/word-search-ii)| [Python](./python/212%20Word%20Search%20II.py) [Java]() |Hard|| +|336|[Palindrome Pairs](https://leetcode.com/problems/palindrome-pairs)| [Python](./python/336%20Palindrome%20Pairs.py) [Java]() |Hard|| +|421|[Maximum XOR of Two Numbers in an Array](https://leetcode.com/problems/maximum-xor-of-two-numbers-in-an-array)| [Python](./python/421%20Maximum%20XOR%20of%20Two%20Numbers%20in%20an%20Array.py) [Java]() |Medium|| +|425|[Word Squares](https://leetcode.com/problems/word-squares)| [Python](./python/425%20Word%20Squares.py) [Java]() |Hard|| +|472|[Concatenated Words](https://leetcode.com/problems/concatenated-words)| [Python](./python/472%20Concatenated%20Words.py) [Java]() |Hard|| ## Binary Indexed Tree | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|218|[The Skyline Problem](https://leetcode.com/problems/the-skyline-problem)|[Python](./python/218 The Skyline Problem.py) [Java]()|Hard|| -|307|[Range Sum Query - Mutable](https://leetcode.com/problems/range-sum-query---mutable)|[Python](./python/307 Range Sum Query - Mutable.py) [Java]()|Medium|| -|308|[Range Sum Query 2D - Mutable](https://leetcode.com/problems/range-sum-query-2d---mutable)|[Python](./python/308 Range Sum Query 2D - Mutable.py) [Java]()|Hard|| -|315|[Count of Smaller Numbers After Self](https://leetcode.com/problems/count-of-smaller-numbers-after-self)|[Python](./python/315 Count of Smaller Numbers After Self.py) [Java]()|Hard|| -|493|[Reverse Pairs](https://leetcode.com/problems/reverse-pairs)|[Python](./python/493 Reverse Pairs.py) [Java]()|Hard|| +|218|[The Skyline Problem](https://leetcode.com/problems/the-skyline-problem)| [Python](./python/218%20The%20Skyline%20Problem.py) [Java]() |Hard|| +|307|[Range Sum Query - Mutable](https://leetcode.com/problems/range-sum-query---mutable)| [Python](./python/307%20Range%20Sum%20Query%20-%20Mutable.py) [Java]() |Medium|| +|308|[Range Sum Query 2D - Mutable](https://leetcode.com/problems/range-sum-query-2d---mutable)| [Python](./python/308%20Range%20Sum%20Query%202D%20-%20Mutable.py) [Java]() |Hard|| +|315|[Count of Smaller Numbers After Self](https://leetcode.com/problems/count-of-smaller-numbers-after-self)| [Python](./python/315%20Count%20of%20Smaller%20Numbers%20After%20Self.py) [Java]() |Hard|| +|493|[Reverse Pairs](https://leetcode.com/problems/reverse-pairs)| [Python](./python/493%20Reverse%20Pairs.py) [Java]() |Hard|| ## Segment Tree | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|218|[The Skyline Problem](https://leetcode.com/problems/the-skyline-problem)|[Python](./python/218 The Skyline Problem.py) [Java]()|Hard|| -|307|[Range Sum Query - Mutable](https://leetcode.com/problems/range-sum-query---mutable)|[Python](./python/307 Range Sum Query - Mutable.py) [Java]()|Medium|| -|308|[Range Sum Query 2D - Mutable](https://leetcode.com/problems/range-sum-query-2d---mutable)|[Python](./python/308 Range Sum Query 2D - Mutable.py) [Java]()|Hard|| -|315|[Count of Smaller Numbers After Self](https://leetcode.com/problems/count-of-smaller-numbers-after-self)|[Python](./python/315 Count of Smaller Numbers After Self.py) [Java]()|Hard|| -|493|[Reverse Pairs](https://leetcode.com/problems/reverse-pairs)|[Python](./python/493 Reverse Pairs.py) [Java]()|Hard|| +|218|[The Skyline Problem](https://leetcode.com/problems/the-skyline-problem)| [Python](./python/218%20The%20Skyline%20Problem.py) [Java]() |Hard|| +|307|[Range Sum Query - Mutable](https://leetcode.com/problems/range-sum-query---mutable)| [Python](./python/307%20Range%20Sum%20Query%20-%20Mutable.py) [Java]() |Medium|| +|308|[Range Sum Query 2D - Mutable](https://leetcode.com/problems/range-sum-query-2d---mutable)| [Python](./python/308%20Range%20Sum%20Query%202D%20-%20Mutable.py) [Java]() |Hard|| +|315|[Count of Smaller Numbers After Self](https://leetcode.com/problems/count-of-smaller-numbers-after-self)| [Python](./python/315%20Count%20of%20Smaller%20Numbers%20After%20Self.py) [Java]() |Hard|| +|493|[Reverse Pairs](https://leetcode.com/problems/reverse-pairs)| [Python](./python/493%20Reverse%20Pairs.py) [Java]() |Hard|| ## Binary Search Tree | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|220|[Contains Duplicate III](https://leetcode.com/problems/contains-duplicate-iii)|[Python](./python/220 Contains Duplicate III.py) [Java]()|Medium|| -|315|[Count of Smaller Numbers After Self](https://leetcode.com/problems/count-of-smaller-numbers-after-self)|[Python](./python/315 Count of Smaller Numbers After Self.py) [Java]()|Hard|| -|327|[Count of Range Sum](https://leetcode.com/problems/count-of-range-sum)|[Python](./python/327 Count of Range Sum.py) [Java]()|Hard|| -|352|[Data Stream as Disjoint Intervals](https://leetcode.com/problems/data-stream-as-disjoint-intervals)|[Python](./python/352 Data Stream as Disjoint Intervals.py) [Java]()|Hard|| -|493|[Reverse Pairs](https://leetcode.com/problems/reverse-pairs)|[Python](./python/493 Reverse Pairs.py) [Java]()|Hard|| -|530|[Minimum Absolute Difference in BST](https://leetcode.com/problems/minimum-absolute-difference-in-bst)|[Python](./python/530 Minimum Absolute Difference in BST.py) [Java]()|Easy|| +|220|[Contains Duplicate III](https://leetcode.com/problems/contains-duplicate-iii)| [Python](./python/220%20Contains%20Duplicate%20III.py) [Java]() |Medium|| +|315|[Count of Smaller Numbers After Self](https://leetcode.com/problems/count-of-smaller-numbers-after-self)| [Python](./python/315%20Count%20of%20Smaller%20Numbers%20After%20Self.py) [Java]() |Hard|| +|327|[Count of Range Sum](https://leetcode.com/problems/count-of-range-sum)| [Python](./python/327%20Count%20of%20Range%20Sum.py) [Java]() |Hard|| +|352|[Data Stream as Disjoint Intervals](https://leetcode.com/problems/data-stream-as-disjoint-intervals)| [Python](./python/352%20Data%20Stream%20as%20Disjoint%20Intervals.py) [Java]() |Hard|| +|493|[Reverse Pairs](https://leetcode.com/problems/reverse-pairs)| [Python](./python/493%20Reverse%20Pairs.py) [Java]() |Hard|| +|530|[Minimum Absolute Difference in BST](https://leetcode.com/problems/minimum-absolute-difference-in-bst)| [Python](./python/530%20Minimum%20Absolute%20Difference%20in%20BST.py) [Java]() |Easy|| ## Recursion | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|247|[Strobogrammatic Number II](https://leetcode.com/problems/strobogrammatic-number-ii)|[Python](./python/247 Strobogrammatic Number II.py) [Java]()|Medium|| -|248|[Strobogrammatic Number III](https://leetcode.com/problems/strobogrammatic-number-iii)|[Python](./python/248 Strobogrammatic Number III.py) [Java]()|Hard|| -|544|[Output Contest Matches](https://leetcode.com/problems/output-contest-matches)|[Python](./python/544 Output Contest Matches.py) [Java]()|Medium|| +|247|[Strobogrammatic Number II](https://leetcode.com/problems/strobogrammatic-number-ii)| [Python](./python/247%20Strobogrammatic%20Number%20II.py) [Java]() |Medium|| +|248|[Strobogrammatic Number III](https://leetcode.com/problems/strobogrammatic-number-iii)| [Python](./python/248%20Strobogrammatic%20Number%20III.py) [Java]() |Hard|| +|544|[Output Contest Matches](https://leetcode.com/problems/output-contest-matches)| [Python](./python/544%20Output%20Contest%20Matches.py) [Java]() |Medium|| ## Brainteaser | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|292|[Nim Game](https://leetcode.com/problems/nim-game)|[Python](./python/292 Nim Game.py) [Java]()|Easy|| -|319|[Bulb Switcher](https://leetcode.com/problems/bulb-switcher)|[Python](./python/319 Bulb Switcher.py) [Java]()|Medium|| +|292|[Nim Game](https://leetcode.com/problems/nim-game)| [Python](./python/292%20Nim%20Game.py) [Java]() |Easy|| +|319|[Bulb Switcher](https://leetcode.com/problems/bulb-switcher)| [Python](./python/319%20Bulb%20Switcher.py) [Java]() |Medium|| ## Memoization | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|329|[Longest Increasing Path in a Matrix](https://leetcode.com/problems/longest-increasing-path-in-a-matrix)|[Python](./python/329 Longest Increasing Path in a Matrix.py) [Java]()|Hard|| +|329|[Longest Increasing Path in a Matrix](https://leetcode.com/problems/longest-increasing-path-in-a-matrix)| [Python](./python/329%20Longest%20Increasing%20Path%20in%20a%20Matrix.py) [Java]() |Hard|| ## Queue | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|346|[Moving Average from Data Stream](https://leetcode.com/problems/moving-average-from-data-stream)|[Python](./python/346 Moving Average from Data Stream.py) [Java]()|Easy|| -|353|[Design Snake Game](https://leetcode.com/problems/design-snake-game)|[Python](./python/353 Design Snake Game.py) [Java]()|Medium|| -|363|[Max Sum of Rectangle No Larger Than K](https://leetcode.com/problems/max-sum-of-rectangle-no-larger-than-k)|[Python](./python/363 Max Sum of Rectangle No Larger Than K.py) [Java]()|Hard|| +|346|[Moving Average from Data Stream](https://leetcode.com/problems/moving-average-from-data-stream)| [Python](./python/346%20Moving%20Average%20from%20Data%20Stream.py) [Java]() |Easy|| +|353|[Design Snake Game](https://leetcode.com/problems/design-snake-game)| [Python](./python/353%20Design%20Snake%20Game.py) [Java]() |Medium|| +|363|[Max Sum of Rectangle No Larger Than K](https://leetcode.com/problems/max-sum-of-rectangle-no-larger-than-k)| [Python](./python/363%20Max%20Sum%20of%20Rectangle%20No%20Larger%20Than%20K.py) [Java]() |Hard|| ## Minimax | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|375|[Guess Number Higher or Lower II](https://leetcode.com/problems/guess-number-higher-or-lower-ii)|[Python](./python/375 Guess Number Higher or Lower II.py) [Java]()|Medium|| -|464|[Can I Win](https://leetcode.com/problems/can-i-win)|[Python](./python/464 Can I Win.py) [Java]()|Medium|| -|486|[Predict the Winner](https://leetcode.com/problems/predict-the-winner)|[Python](./python/486 Predict the Winner.py) [Java]()|Medium|| +|375|[Guess Number Higher or Lower II](https://leetcode.com/problems/guess-number-higher-or-lower-ii)| [Python](./python/375%20Guess%20Number%20Higher%20or%20Lower%20II.py) [Java]() |Medium|| +|464|[Can I Win](https://leetcode.com/problems/can-i-win)| [Python](./python/464%20Can%20I%20Win.py) [Java]() |Medium|| +|486|[Predict the Winner](https://leetcode.com/problems/predict-the-winner)| [Python](./python/486%20Predict%20the%20Winner.py) [Java]() |Medium|| ## Reservoir Sampling | # | Title | Solution | Difficulty | Note | |-----|---------------- | --------------- | --------------- | --------------- | -|382|[Linked List Random Node](https://leetcode.com/problems/linked-list-random-node)|[Python](./python/382 Linked List Random Node.py) [Java]()|Medium|| -|398|[Random Pick Index](https://leetcode.com/problems/random-pick-index)|[Python](./python/398 Random Pick Index.py) [Java]()|Medium|| \ No newline at end of file +|382|[Linked List Random Node](https://leetcode.com/problems/linked-list-random-node)| [Python](./python/382%20Linked%20List%20Random%20Node.py) [Java]() |Medium|| +|398|[Random Pick Index](https://leetcode.com/problems/random-pick-index)| [Python](./python/398%20Random%20Pick%20Index.py) [Java]() |Medium|| \ No newline at end of file From 9ae701493a5ad77dfaeb4d5ac6f0fffad2bf7b9d Mon Sep 17 00:00:00 2001 From: Shen Jie Date: Wed, 3 May 2017 22:49:35 +0800 Subject: [PATCH 14/53] Update tag info in readme --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b0ad448..20eab7b 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![Language](https://img.shields.io/badge/python-3.5-blue.svg)](https://www.python.org) [![License](https://img.shields.io/dub/l/vibe-d.svg)](https://opensource.org/licenses/MIT) -This repository shares my leetcode problems solving experience. The first edition is written in Python3, and now I am working on resolving them with Java8. There are articles describing the solution. For further information, please see the Articles part. +This repository shares my experience in solving leetcode problems. The first edition was written in Python3, and now I am working on resolving them with Java8. There are articles describing the solution. For further information, please see the Articles part. ## Problems @@ -13,6 +13,10 @@ You can find all the problems on [LeetCode](https://leetcode.com). You are welcome if you have any question or suggestion. +## Tag + +I have classified the problems into different tags like the leetcode OJ does. You can check them [here](./TAG.md). + ## Articles There are articles about each problem, describing how I solve that problem. You can visit them on [GitBook](https://shenjie1993.gitbooks.io/leetcode-python/content/) or [CSDN](http://blog.csdn.net/column/details/leetcode-python.html). From 7b38a2b4d350b7e1f29d716c19927edafd5c0d1f Mon Sep 17 00:00:00 2001 From: Shen Jie Date: Wed, 3 May 2017 22:54:36 +0800 Subject: [PATCH 15/53] Fix link error of 432 in Design tag --- TAG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TAG.md b/TAG.md index 51478b3..f773da4 100644 --- a/TAG.md +++ b/TAG.md @@ -846,7 +846,7 @@ |379|[Design Phone Directory](https://leetcode.com/problems/design-phone-directory)| [Python](./python/379%20Design%20Phone%20Directory.py) [Java]() |Medium|| |380|[Insert Delete GetRandom O(1)](https://leetcode.com/problems/insert-delete-getrandom-o(1))| [Python](./python/380%20Insert%20Delete%20GetRandom%20O(1).py) [Java]() |Medium|| |381|[Insert Delete GetRandom O(1) - Duplicates allowed](https://leetcode.com/problems/insert-delete-getrandom-o(1)---duplicates-allowed)| [Python](./python/381%20Insert%20Delete%20GetRandom%20O(1)%20-%20Duplicates%20allowed.py) [Java]() |Hard|| -|432|[All O`one Data Structure](https://leetcode.com/problems/all-o`one-data-structure)| [Python](./python/432%20All%20O`one%20Data%20Structure.py) [Java]() |Hard|| +|432|[All O`one Data Structure](https://leetcode.com/problems/all-oone-data-structure)| [Python](./python/432%20All%20O`one%20Data%20Structure.py) [Java]() |Hard|| |460|[LFU Cache](https://leetcode.com/problems/lfu-cache)| [Python](./python/460%20LFU%20Cache.py) [Java]() |Hard|| ## Topological Sort From dfc02bcd9ab2264c8a5a57e7521e56fb8a385282 Mon Sep 17 00:00:00 2001 From: Shen Jie Date: Thu, 4 May 2017 11:19:26 +0800 Subject: [PATCH 16/53] Enhancement for #1 --- python/005 Longest Palindromic Substring.py | 26 +++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/python/005 Longest Palindromic Substring.py b/python/005 Longest Palindromic Substring.py index 5a6d719..46487a9 100644 --- a/python/005 Longest Palindromic Substring.py +++ b/python/005 Longest Palindromic Substring.py @@ -2,8 +2,9 @@ Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring. ''' + class Solution(object): - def longestPalindrome(self, s): + def longestPalindrome2(self, s): """ :type s: str :rtype: str @@ -21,7 +22,8 @@ def longestPalindrome(self, s): m = 0 # Length of the current substring c = 0 - # Whether the substring contains the first character or last character and is palindromic + # Whether the substring contains the first character or last character + # and is palindromic b = True for i in range(0, n): # Odd situation @@ -50,6 +52,26 @@ def longestPalindrome(self, s): b = True return s[l:r] + def longestPalindrome(self, s): + string = "#" + "#".join(s) + "#" + i = 0 + maxBorder = 0 # store the max border that has been reached + maxCenter = 0 # the center of palindrome that has been largest for now + p = [0 for _ in range(len(string))] # min in (center to i or i to border) + res = [0, 0] + + while i < len(string): + p[i] = min(p[2 * maxCenter - i], maxBorder - i) if maxBorder > i else 1 + while i - p[i] >= 0 and i + p[i] < len(string) and string[i - p[i]] == string[i + p[i]]: + p[i] += 1 + if maxBorder < p[i] + i: + maxBorder = p[i] + i + maxCenter = i + if maxBorder - maxCenter > res[1] - res[0]: + res = [maxCenter, maxBorder] + i += 1 + + return "".join([x for x in string[2 * res[0] - res[1] + 1:res[1]] if x != '#']) if __name__ == "__main__": From 49517bd3eed87d3c3a6fa39189704041189de29c Mon Sep 17 00:00:00 2001 From: Shen Jie Date: Thu, 4 May 2017 23:17:15 +0800 Subject: [PATCH 17/53] Java solution 001/004 --- java/_001TwoSum.java | 29 ++++++++++++++++ java/_004MedianOfTwoSortedArrays.java | 50 +++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 java/_001TwoSum.java create mode 100644 java/_004MedianOfTwoSortedArrays.java diff --git a/java/_001TwoSum.java b/java/_001TwoSum.java new file mode 100644 index 0000000..10f10fd --- /dev/null +++ b/java/_001TwoSum.java @@ -0,0 +1,29 @@ +import java.util.HashMap; +import java.util.Map; + +/** + * Given an array of integers, return indices of the two numbers such that they add up to a specific target. + * You may assume that each input would have exactly one solution, and you may not use the same element twice. + *

+ * Example: + * Given nums = [2, 7, 11, 15], target = 9, + * Because nums[0] + nums[1] = 2 + 7 = 9, + * return [0, 1]. + *

+ * Created by drfish on 04/05/2017. + */ +public class _001TwoSum { + public int[] twoSum(int[] nums, int target) { + int[] result = new int[2]; + Map map = new HashMap<>(); + for (int i = 0; i < nums.length; i++) { + if (map.containsKey(target - nums[i])) { + result[0] = map.get(target - nums[i]); + result[1] = i; + return result; + } + map.put(nums[i], i); + } + return result; + } +} diff --git a/java/_004MedianOfTwoSortedArrays.java b/java/_004MedianOfTwoSortedArrays.java new file mode 100644 index 0000000..fd597f2 --- /dev/null +++ b/java/_004MedianOfTwoSortedArrays.java @@ -0,0 +1,50 @@ +import com.sun.org.apache.regexp.internal.recompile; + +/** + * There are two sorted arrays nums1 and nums2 of size m and n respectively. + * Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). + *

+ * Example 1: + * nums1 = [1, 3] + * nums2 = [2] + * The median is 2.0 + *

+ * Example 2: + * nums1 = [1, 2] + * nums2 = [3, 4] + * The median is (2 + 3)/2 = 2.5 + *

+ * Created by drfish on 04/05/2017. + */ +public class _004MedianOfTwoSortedArrays { + public double findMedianSortedArrays(int[] nums1, int[] nums2) { + int k1 = (nums1.length + nums2.length + 1) / 2; + int k2 = (nums1.length + nums2.length + 2) / 2; + return (findK(nums1, 0, nums2, 0, k1) + findK(nums1, 0, nums2, 0, k2)) / 2.0; + } + + private double findK(int[] nums1, int start1, int[] nums2, int start2, int k) { + if (start1 >= nums1.length) { + return nums2[start2 + k - 1]; + } + if (start2 >= nums2.length) { + return nums1[start1 + k - 1]; + } + if (k == 1) { + return Math.min(nums1[start1], nums2[start2]); + } + int mid1 = Integer.MAX_VALUE; + int mid2 = Integer.MAX_VALUE; + if (start1 + k / 2 - 1 < nums1.length) { + mid1 = nums1[start1 + k / 2 - 1]; + } + if (start2 + k / 2 - 1 < nums2.length) { + mid2 = nums2[start2 + k / 2 - 1]; + } + if (mid1 < mid2) { + return findK(nums1, start1 + k / 2, nums2, start2, k - k / 2); + } else { + return findK(nums1, start1, nums2, start2 + k / 2, k - k / 2); + } + } +} From cf3685440747d2eb581074f1f533c33601cf1f2e Mon Sep 17 00:00:00 2001 From: Shen Jie Date: Sat, 13 May 2017 23:33:00 +0800 Subject: [PATCH 18/53] Java solution 003 --- ...stSubStringWithoutRepeatingCharacters.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 java/_003LongestSubStringWithoutRepeatingCharacters.java diff --git a/java/_003LongestSubStringWithoutRepeatingCharacters.java b/java/_003LongestSubStringWithoutRepeatingCharacters.java new file mode 100644 index 0000000..f5083f2 --- /dev/null +++ b/java/_003LongestSubStringWithoutRepeatingCharacters.java @@ -0,0 +1,39 @@ +import java.util.HashMap; +import java.util.Map; + +/** + * Given a string, find the length of the longest substring without repeating characters. + *

+ * Examples: + * Given "abcabcbb", the answer is "abc", which the length is 3. + * Given "bbbbb", the answer is "b", with the length of 1. + * Given "pwwkew", the answer is "wke", with the length of 3. Note that the answer must be a substring, "pwke" is a + * subsequence and not a substring. + * Created by drfish on 13/05/2017. + */ +public class _003LongestSubStringWithoutRepeatingCharacters { + public int lengthOfLongestSubstring(String s) { + if (s == null) + return 0; + if (s.length() <= 1) + return s.length(); + Map map = new HashMap<>(); + int start = -1; + int result = 0; + for (int i = 0; i < s.length(); i++) { + if (map.containsKey(s.charAt(i))) { + start = Math.max(start, map.get(s.charAt(i))); + } + map.put(s.charAt(i), i); + result = Math.max(result, i - start); + } + return result; + } + + public static void main(String[] args) { + _003LongestSubStringWithoutRepeatingCharacters solution = new _003LongestSubStringWithoutRepeatingCharacters(); + assert 3 == solution.lengthOfLongestSubstring("abcabcbb"); + assert 1 == solution.lengthOfLongestSubstring("bbbbb"); + assert 3 == solution.lengthOfLongestSubstring("pwwkew"); + } +} From ef34e89fe38e29b00fc9f4d36420f7dde6be5d8b Mon Sep 17 00:00:00 2001 From: Shen Jie Date: Sat, 27 May 2017 22:58:29 +0800 Subject: [PATCH 19/53] Java solution 94 && 96 --- java/_094BinaryTreeInorderTraversal.java | 49 ++++++++++++++++++++++++ java/_096UniqueBinarySearchTrees.java | 34 ++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 java/_094BinaryTreeInorderTraversal.java create mode 100644 java/_096UniqueBinarySearchTrees.java diff --git a/java/_094BinaryTreeInorderTraversal.java b/java/_094BinaryTreeInorderTraversal.java new file mode 100644 index 0000000..d007b28 --- /dev/null +++ b/java/_094BinaryTreeInorderTraversal.java @@ -0,0 +1,49 @@ +/** + * Given a binary tree, return the inorder traversal of its nodes' values. + *

+ * For example: + * Given binary tree [1,null,2,3], + * 1 + * \ + * 2 + * / + * 3 + * return [1,3,2]. + *

+ * Note: Recursive solution is trivial, could you do it iteratively? + * Created by drfish on 27/05/2017. + */ + +import java.util.ArrayList; +import java.util.List; +import java.util.Stack; + +/** + * Definition for a binary tree node. + */ +class TreeNode { + int val; + TreeNode left; + TreeNode right; + + TreeNode(int x) { + val = x; + } +} + +public class _094BinaryTreeInorderTraversal { + public List inorderTraversal(TreeNode root) { + Stack stack = new Stack<>(); + List result = new ArrayList<>(); + while (root != null || !stack.empty()) { + while (root != null) { + stack.add(root); + root = root.left; + } + root = stack.pop(); + result.add(root.val); + root = root.right; + } + return result; + } +} diff --git a/java/_096UniqueBinarySearchTrees.java b/java/_096UniqueBinarySearchTrees.java new file mode 100644 index 0000000..25b8be2 --- /dev/null +++ b/java/_096UniqueBinarySearchTrees.java @@ -0,0 +1,34 @@ +/** + * Given n, how many structurally unique BST's (binary search trees) that store values 1...n? + *

+ * For example, + * Given n = 3, there are a total of 5 unique BST's. + *

+ * 1 3 3 2 1 + * \ / / / \ \ + * 3 2 1 1 3 2 + * / / \ \ + * 2 1 2 3 + *

+ * Created by drfish on 27/05/2017. + */ +public class _096UniqueBinarySearchTrees { + public int numTrees(int n) { + int[] counts = new int[n + 1]; + counts[0] = 1; + for (int i = 1; i <= n; i++) { + int count = 0; + for (int j = 0; j < i; j++) { + count += counts[j] * counts[i - 1 - j]; + } + counts[i] = count; + } + return counts[n]; + } + + public static void main(String[] args) { + _096UniqueBinarySearchTrees uniqueBinarySearchTrees = new _096UniqueBinarySearchTrees(); + System.out.println(uniqueBinarySearchTrees.numTrees(6)); + assert uniqueBinarySearchTrees.numTrees(3) == 5; + } +} From 70da5848090fc1229cbbe28c55cb124783a889d7 Mon Sep 17 00:00:00 2001 From: Shen Jie Date: Sat, 27 May 2017 23:01:31 +0800 Subject: [PATCH 20/53] Rename java solution 23 && 25 --- java/{_023MergekSortedLists.java => _023MergeKSortedLists.java} | 2 +- ..._25ReverNodesInkGroup.java => _025ReverseNodesInKGroup.java} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename java/{_023MergekSortedLists.java => _023MergeKSortedLists.java} (95%) rename java/{_25ReverNodesInkGroup.java => _025ReverseNodesInKGroup.java} (97%) diff --git a/java/_023MergekSortedLists.java b/java/_023MergeKSortedLists.java similarity index 95% rename from java/_023MergekSortedLists.java rename to java/_023MergeKSortedLists.java index f299b58..3b803ab 100644 --- a/java/_023MergekSortedLists.java +++ b/java/_023MergeKSortedLists.java @@ -5,7 +5,7 @@ *

* Created by drfish on 16/04/2017. */ -public class _023MergekSortedLists { +public class _023MergeKSortedLists { public ListNode mergeKLists(ListNode[] lists) { PriorityQueue nodesHeap = new PriorityQueue((n1, n2) -> (n1.val - n2.val)); for (ListNode node : lists) { diff --git a/java/_25ReverNodesInkGroup.java b/java/_025ReverseNodesInKGroup.java similarity index 97% rename from java/_25ReverNodesInkGroup.java rename to java/_025ReverseNodesInKGroup.java index 8b3f9c9..f0606db 100644 --- a/java/_25ReverNodesInkGroup.java +++ b/java/_025ReverseNodesInKGroup.java @@ -16,7 +16,7 @@ *

* Created by drfish on 16/04/2017. */ -public class _25ReverNodesInkGroup { +public class _025ReverseNodesInKGroup { public ListNode reverseKGroup(ListNode head, int k) { if (head == null || k <= 1) return head; From c5444b820acb0dc122a1a62efdd1aca60a67aa54 Mon Sep 17 00:00:00 2001 From: Shen Jie Date: Sat, 27 May 2017 23:07:49 +0800 Subject: [PATCH 21/53] Polish test cases for java 96 --- java/_096UniqueBinarySearchTrees.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/_096UniqueBinarySearchTrees.java b/java/_096UniqueBinarySearchTrees.java index 25b8be2..e13e81e 100644 --- a/java/_096UniqueBinarySearchTrees.java +++ b/java/_096UniqueBinarySearchTrees.java @@ -28,7 +28,7 @@ public int numTrees(int n) { public static void main(String[] args) { _096UniqueBinarySearchTrees uniqueBinarySearchTrees = new _096UniqueBinarySearchTrees(); - System.out.println(uniqueBinarySearchTrees.numTrees(6)); assert uniqueBinarySearchTrees.numTrees(3) == 5; + assert uniqueBinarySearchTrees.numTrees(6) == 132; } } From 40d975609358b513046564374767c0fc3bf8d54e Mon Sep 17 00:00:00 2001 From: Shen Jie Date: Sat, 27 May 2017 23:36:11 +0800 Subject: [PATCH 22/53] Java solution 95 --- java/_095UniqueBinarySearchTreesII.java | 36 +++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 java/_095UniqueBinarySearchTreesII.java diff --git a/java/_095UniqueBinarySearchTreesII.java b/java/_095UniqueBinarySearchTreesII.java new file mode 100644 index 0000000..7da5566 --- /dev/null +++ b/java/_095UniqueBinarySearchTreesII.java @@ -0,0 +1,36 @@ +import java.util.ArrayList; +import java.util.List; + +/** + * Created by drfish on 27/05/2017. + */ +public class _095UniqueBinarySearchTreesII { + public List generateTrees(int n) { + List result = genTrees(1, n); + if (result.get(0) == null) { + return new ArrayList<>(); + } else { + return result; + } + } + + private List genTrees(int start, int end) { + List result = new ArrayList<>(); + if (start > end) { + result.add(null); + } + for (int i = start; i <= end; i++) { + List leftTrees = genTrees(start, i - 1); + List rightTrees = genTrees(i + 1, end); + for (TreeNode leftTree : leftTrees) { + for (TreeNode rightTree : rightTrees) { + TreeNode root = new TreeNode(i); + root.left = leftTree; + root.right = rightTree; + result.add(root); + } + } + } + return result; + } +} From 360bec9ca6872979d814da6571c3dd2ab64a8f2a Mon Sep 17 00:00:00 2001 From: Shen Jie Date: Sun, 28 May 2017 10:27:40 +0800 Subject: [PATCH 23/53] Add description for java 95 --- java/_095UniqueBinarySearchTreesII.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/java/_095UniqueBinarySearchTreesII.java b/java/_095UniqueBinarySearchTreesII.java index 7da5566..fefbc12 100644 --- a/java/_095UniqueBinarySearchTreesII.java +++ b/java/_095UniqueBinarySearchTreesII.java @@ -2,6 +2,17 @@ import java.util.List; /** + * Given an integer n, generate all structurally unique BST's (binary search trees) that store values 1...n. + *

+ * For example, + * Given n = 3, your program should return all 5 unique BST's shown below. + *

+ * 1 3 3 2 1 + * \ / / / \ \ + * 3 2 1 1 3 2 + * / / \ \ + * 2 1 2 3 + *

* Created by drfish on 27/05/2017. */ public class _095UniqueBinarySearchTreesII { From b0ad2bc34d7ed85a76a9190d196e668dc8d9f779 Mon Sep 17 00:00:00 2001 From: Shen Jie Date: Sun, 28 May 2017 13:26:25 +0800 Subject: [PATCH 24/53] Java solution 98 && 99 --- java/_098ValidateBinarySearchTree.java | 45 ++++++++++++++++++++++++++ java/_099RecoverBinarySearchTree.java | 41 +++++++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 java/_098ValidateBinarySearchTree.java create mode 100644 java/_099RecoverBinarySearchTree.java diff --git a/java/_098ValidateBinarySearchTree.java b/java/_098ValidateBinarySearchTree.java new file mode 100644 index 0000000..2719148 --- /dev/null +++ b/java/_098ValidateBinarySearchTree.java @@ -0,0 +1,45 @@ +import java.util.Stack; + +/** + * Given a binary tree, determine if it is a valid binary search tree (BST). + *

+ * Assume a BST is defined as follows: + * The left subtree of a node contains only nodes with keys less than the node's key. + * The right subtree of a node contains only nodes with keys greater than the node's key. + * Both the left and right subtrees must also be binary search trees. + *

+ * Example 1: + * 2 + * / \ + * 1 3 + * Binary tree [2,1,3], return true. + * Example 2: + * 1 + * / \ + * 2 3 + * Binary tree [1,2,3], return false. + *

+ * Created by drfish on 28/05/2017. + */ +public class _098ValidateBinarySearchTree { + public boolean isValidBST(TreeNode root) { + if (root == null) { + return true; + } + Stack stack = new Stack<>(); + TreeNode prev = null; + while (root != null || !stack.isEmpty()) { + while (root != null) { + stack.push(root); + root = root.left; + } + root = stack.pop(); + if (prev != null && prev.val >= root.val) { + return false; + } + prev = root; + root = root.right; + } + return true; + } +} diff --git a/java/_099RecoverBinarySearchTree.java b/java/_099RecoverBinarySearchTree.java new file mode 100644 index 0000000..afd6f7f --- /dev/null +++ b/java/_099RecoverBinarySearchTree.java @@ -0,0 +1,41 @@ +import java.util.Stack; + +/** + * Two elements of a binary search tree (BST) are swapped by mistake. + * Recover the tree without changing its structure. + *

+ * Note: + * A solution using O(n) space is pretty straight forward. Could you devise a constant space solution? + *

+ * Created by drfish on 28/05/2017. + */ +public class _099RecoverBinarySearchTree { + public void recoverTree(TreeNode root) { + TreeNode first = null; + TreeNode second = null; + TreeNode prev = null; + Stack stack = new Stack<>(); + while (root != null || !stack.isEmpty()) { + while (root != null) { + stack.push(root); + root = root.left; + } + root = stack.pop(); + if (prev != null && prev.val >= root.val) { + if (first == null) { + first = prev; + } + second = root; + } + prev = root; + root = root.right; + } + swap(first, second); + } + + private void swap(TreeNode node1, TreeNode node2) { + int temp = node1.val; + node1.val = node2.val; + node2.val = temp; + } +} From 77e5f4297ab8f6b80e1174315c88b652559e07bc Mon Sep 17 00:00:00 2001 From: Shen Jie Date: Sun, 28 May 2017 13:28:22 +0800 Subject: [PATCH 25/53] Polish Java 94 --- java/_094BinaryTreeInorderTraversal.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/_094BinaryTreeInorderTraversal.java b/java/_094BinaryTreeInorderTraversal.java index d007b28..6508a54 100644 --- a/java/_094BinaryTreeInorderTraversal.java +++ b/java/_094BinaryTreeInorderTraversal.java @@ -37,7 +37,7 @@ public List inorderTraversal(TreeNode root) { List result = new ArrayList<>(); while (root != null || !stack.empty()) { while (root != null) { - stack.add(root); + stack.push(root); root = root.left; } root = stack.pop(); From 5b0c3f07bbbef8b6b0449a2651ad7fe42700cdb0 Mon Sep 17 00:00:00 2001 From: Shen Jie Date: Sun, 28 May 2017 23:02:23 +0800 Subject: [PATCH 26/53] Java solution 100 && 101 --- java/_100SameTree.java | 19 +++++++++++++++++ java/_101SymmetricTree.java | 41 +++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 java/_100SameTree.java create mode 100644 java/_101SymmetricTree.java diff --git a/java/_100SameTree.java b/java/_100SameTree.java new file mode 100644 index 0000000..8fa0ce5 --- /dev/null +++ b/java/_100SameTree.java @@ -0,0 +1,19 @@ +/** + * Given two binary trees, write a function to check if they are equal or not. + * Two binary trees are considered equal if they are structurally identical and the nodes have the same value. + *

+ * Created by drfish on 28/05/2017. + */ +public class _100SameTree { + public boolean isSameTree(TreeNode p, TreeNode q) { + if (p == null && q == null) { + return true; + } + if (p != null && q != null) { + if (p.val == q.val) { + return isSameTree(p.left, q.left) && isSameTree(p.right, q.right); + } + } + return false; + } +} diff --git a/java/_101SymmetricTree.java b/java/_101SymmetricTree.java new file mode 100644 index 0000000..12b5e4b --- /dev/null +++ b/java/_101SymmetricTree.java @@ -0,0 +1,41 @@ +/** + * Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). + *

+ * For example, this binary tree [1,2,2,3,4,4,3] is symmetric: + * 1 + * / \ + * 2 2 + * / \ / \ + * 3 4 4 3 + * But the following [1,2,2,null,3,null,3] is not: + * 1 + * / \ + * 2 2 + * \ \ + * 3 3 + *

+ * Note: + * Bonus points if you could solve it both recursively and iteratively. + *

+ * Created by drfish on 28/05/2017. + */ +public class _101SymmetricTree { + public boolean isSymmetric(TreeNode root) { + if (root == null) { + return true; + } + return check(root.left, root.right); + } + + private boolean check(TreeNode p, TreeNode q) { + if (p == null && q == null) { + return true; + } + if (p != null && q != null) { + if (p.val == q.val) { + return check(p.left, q.right) && check(p.right, q.left); + } + } + return false; + } +} From 8117da9dff3db3dffe6666170ba84b8fdfc294e6 Mon Sep 17 00:00:00 2001 From: drfish Date: Wed, 7 Jun 2017 19:08:39 +0800 Subject: [PATCH 27/53] Java solution 20 && 42 --- java/_020ValidParentheses.java | 42 +++++++++++++++++++++++++++ java/_042TrappingRainWater.java | 50 +++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 java/_020ValidParentheses.java create mode 100644 java/_042TrappingRainWater.java diff --git a/java/_020ValidParentheses.java b/java/_020ValidParentheses.java new file mode 100644 index 0000000..02a6d75 --- /dev/null +++ b/java/_020ValidParentheses.java @@ -0,0 +1,42 @@ +import java.util.Stack; + +/** + * Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. + * The brackets must close in the correct order, "()" and "()[]{}" are all valid but "(]" and "([)]" are not. + *

+ * Created by drfish on 6/7/2017. + */ +public class _020ValidParentheses { + public boolean isValid(String s) { + if (s == null) { + return true; + } + Stack stack = new Stack<>(); + for (char c : s.toCharArray()) { + switch (c) { + case '(': + stack.push(')'); + break; + case '{': + stack.push('}'); + break; + case '[': + stack.push(']'); + break; + default: + if (stack.isEmpty() || stack.pop() != c) { + return false; + } + } + } + return stack.isEmpty(); + } + + public static void main(String[] args) { + _020ValidParentheses solution = new _020ValidParentheses(); + assert solution.isValid("()"); + assert solution.isValid("()[]()"); + assert !solution.isValid("(]"); + assert !solution.isValid("([)]"); + } +} diff --git a/java/_042TrappingRainWater.java b/java/_042TrappingRainWater.java new file mode 100644 index 0000000..6474793 --- /dev/null +++ b/java/_042TrappingRainWater.java @@ -0,0 +1,50 @@ +import java.util.Stack; + +/** + * Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining. + *

+ * For example, + * Given [0,1,0,2,1,0,1,3,2,1,2,1], return 6. + *

+ * The above elevation map is represented by array [0,1,0,2,1,0,1,3,2,1,2,1]. In this case, 6 units of rain water (blue section) are being trapped. Thanks Marcos for contributing this image! + *

+ * Created by drfish on 6/7/2017. + */ +public class _042TrappingRainWater { + public int trap(int[] height) { + if (height == null) { + return 0; + } + int leftIndex = 0; + int rightIndex = height.length - 1; + int leftMax = 0; + int rightMax = 0; + int result = 0; + + while (leftIndex <= rightIndex) { + if (height[leftIndex] <= height[rightIndex]) { + if (height[leftIndex] >= leftMax) { + leftMax = height[leftIndex]; + } else { + result += leftMax - height[leftIndex]; + } + leftIndex++; + } else { + if (height[rightIndex] >= rightMax) { + rightMax = height[rightIndex]; + } else { + result += rightMax - height[rightIndex]; + } + rightIndex--; + } + } + return result; + } + + public static void main(String[] args) { + _042TrappingRainWater solution = new _042TrappingRainWater(); + int[] height = {0, 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1}; + assert 6 == solution.trap(height); + assert 0 == solution.trap(new int[]{0, 2, 0}); + } +} From e5aca269eb8cc2648dccaf6e5c59755b97f19505 Mon Sep 17 00:00:00 2001 From: drfish Date: Wed, 7 Jun 2017 19:54:58 +0800 Subject: [PATCH 28/53] Add .idea in gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 8f49248..5ccd50d 100644 --- a/.gitignore +++ b/.gitignore @@ -58,4 +58,5 @@ target/ # IntelliJ Idea out/ +.idea/ *.iml From 4a07830561748f1d1e0319f6bc9837deb7d7eace Mon Sep 17 00:00:00 2001 From: Shen Jie Date: Wed, 7 Jun 2017 23:47:16 +0800 Subject: [PATCH 29/53] Java solution 102 --- java/_102BinaryTreeLevelOrderTraversal.java | 52 +++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 java/_102BinaryTreeLevelOrderTraversal.java diff --git a/java/_102BinaryTreeLevelOrderTraversal.java b/java/_102BinaryTreeLevelOrderTraversal.java new file mode 100644 index 0000000..0d744c7 --- /dev/null +++ b/java/_102BinaryTreeLevelOrderTraversal.java @@ -0,0 +1,52 @@ +import java.util.ArrayList; +import java.util.List; + +/** + * Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). + *

+ * For example: + * Given binary tree [3,9,20,null,null,15,7], + * 3 + * / \ + * 9 20 + * / \ + * 15 7 + *

+ * return its level order traversal as: + * [ + * [3], + * [9,20], + * [15,7] + * ] + *

+ * Created by drfish on 29/05/2017. + */ +public class _102BinaryTreeLevelOrderTraversal { + public List> levelOrder(TreeNode root) { + List> result = new ArrayList<>(); + List curr = new ArrayList<>(); + + + if (root == null) { + return result; + } + curr.add(root); + + while (!curr.isEmpty()) { + List next = new ArrayList<>(); + List level = new ArrayList<>(); + for (TreeNode node : curr) { + if (node.left != null) { + next.add(node.left); + } + if (node.right != null) { + next.add(node.right); + } + level.add(node.val); + } + result.add(level); + curr = next; + } + return result; + } +} From a4d7a0fef1b907cb3c067c0f456dc3ffdaa05d62 Mon Sep 17 00:00:00 2001 From: Shen Jie Date: Wed, 7 Jun 2017 23:57:23 +0800 Subject: [PATCH 30/53] Polish readme --- README.md | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 20eab7b..31110e5 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # leetcode-share -[![Language](https://img.shields.io/badge/python-3.5-blue.svg)](https://www.python.org) +[![Language python](https://img.shields.io/badge/python-3.5-blue.svg)](https://www.python.org) +[![Language java](https://img.shields.io/badge/java-8-orange.svg)](http://www.oracle.com/technetwork/java/javase/overview/java8-2100321.html) [![License](https://img.shields.io/dub/l/vibe-d.svg)](https://opensource.org/licenses/MIT) This repository shares my experience in solving leetcode problems. The first edition was written in Python3, and now I am working on resolving them with Java8. There are articles describing the solution. For further information, please see the Articles part. @@ -23,24 +24,6 @@ There are articles about each problem, describing how I solve that problem. You It is a pity that they are only in Chinese. -## MIT License +## License -Copyright (c) 2017 Drfish - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +[MIT LICENSE](./LICENSE) \ No newline at end of file From b3c8c1999f935976963f4c5adf531c94f8d5ca2b Mon Sep 17 00:00:00 2001 From: drfish Date: Thu, 8 Jun 2017 09:31:10 +0800 Subject: [PATCH 31/53] Java solution 103 && 144 --- ...03BinaryTreeZigzagLevelOrderTraversal.java | 57 +++++++++++++++++++ java/_144BinaryTreePreorderTraversal.java | 35 ++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 java/_103BinaryTreeZigzagLevelOrderTraversal.java create mode 100644 java/_144BinaryTreePreorderTraversal.java diff --git a/java/_103BinaryTreeZigzagLevelOrderTraversal.java b/java/_103BinaryTreeZigzagLevelOrderTraversal.java new file mode 100644 index 0000000..73cb668 --- /dev/null +++ b/java/_103BinaryTreeZigzagLevelOrderTraversal.java @@ -0,0 +1,57 @@ +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; + +/** + * Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between). + *

+ * For example: + * Given binary tree [3,9,20,null,null,15,7], + * 3 + * / \ + * 9 20 + * / \ + * 15 7 + * return its zigzag level order traversal as: + * [ + * [3], + * [20,9], + * [15,7] + * ] + *

+ * Created by drfish on 6/7/2017. + */ +public class _103BinaryTreeZigzagLevelOrderTraversal { + public List> zigzagLevelOrder(TreeNode root) { + List> result = new ArrayList<>(); + List curr = new ArrayList<>(); + boolean isOdd = true; + + if (root == null) { + return result; + } + curr.add(root); + + while (!curr.isEmpty()) { + List next = new ArrayList<>(); + List level = new LinkedList<>(); + for (TreeNode node : curr) { + if (node.left != null) { + next.add(node.left); + } + if (node.right != null) { + next.add(node.right); + } + if (isOdd) { + level.add(node.val); + } else { + level.add(0, node.val); + } + } + isOdd = !isOdd; + result.add(level); + curr = next; + } + return result; + } +} diff --git a/java/_144BinaryTreePreorderTraversal.java b/java/_144BinaryTreePreorderTraversal.java new file mode 100644 index 0000000..56e9f58 --- /dev/null +++ b/java/_144BinaryTreePreorderTraversal.java @@ -0,0 +1,35 @@ +import java.util.ArrayList; +import java.util.List; +import java.util.Stack; + +/** + * Given a binary tree, return the preorder traversal of its nodes' values. + *

+ * For example: + * Given binary tree {1,#,2,3}, + * 1 + * \ + * 2 + * / + * 3 + * return [1,2,3]. + *

+ * Note: Recursive solution is trivial, could you do it iteratively? + * Created by drfish on 6/8/2017. + */ +public class _144BinaryTreePreorderTraversal { + public List preorderTraversal(TreeNode root) { + List result = new ArrayList<>(); + Stack stack = new Stack<>(); + while (root != null || !stack.isEmpty()) { + while (root != null) { + result.add(root.val); + stack.push(root); + root = root.left; + } + root = stack.pop(); + root = root.right; + } + return result; + } +} From d0fdb9bb267d7fb8f98f6fc34753615469533fe4 Mon Sep 17 00:00:00 2001 From: drfish Date: Thu, 8 Jun 2017 11:00:21 +0800 Subject: [PATCH 32/53] Java solution 145 && 150 --- java/_145BinaryTreePostorderTraversal.java | 35 +++++++++++++++ java/_150EvaluateReversePolishNotation.java | 49 +++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 java/_145BinaryTreePostorderTraversal.java create mode 100644 java/_150EvaluateReversePolishNotation.java diff --git a/java/_145BinaryTreePostorderTraversal.java b/java/_145BinaryTreePostorderTraversal.java new file mode 100644 index 0000000..d0f193e --- /dev/null +++ b/java/_145BinaryTreePostorderTraversal.java @@ -0,0 +1,35 @@ +import java.util.LinkedList; +import java.util.List; +import java.util.Stack; + +/** + * Given a binary tree, return the postorder traversal of its nodes' values. + *

+ * For example: + * Given binary tree {1,#,2,3}, + * 1 + * \ + * 2 + * / + * 3 + * return [3,2,1]. + *

+ * Note: Recursive solution is trivial, could you do it iteratively? + *

+ * Created by drfish on 6/8/2017. + */ +public class _145BinaryTreePostorderTraversal { + public List postorderTraversal(TreeNode root) { + List result = new LinkedList<>(); + Stack stack = new Stack<>(); + while (root != null || !stack.isEmpty()) { + while (root != null) { + stack.push(root); + result.add(0, root.val); + root = root.right; + } + root = stack.pop().left; + } + return result; + } +} diff --git a/java/_150EvaluateReversePolishNotation.java b/java/_150EvaluateReversePolishNotation.java new file mode 100644 index 0000000..c54d0bd --- /dev/null +++ b/java/_150EvaluateReversePolishNotation.java @@ -0,0 +1,49 @@ +import java.util.Stack; + +/** + * Evaluate the value of an arithmetic expression in Reverse Polish Notation. + * Valid operators are +, -, *, /. Each operand may be an integer or another expression. + *

+ * Some examples: + * ["2", "1", "+", "3", "*"] -> ((2 + 1) * 3) -> 9 + * ["4", "13", "5", "/", "+"] -> (4 + (13 / 5)) -> 6 + *

+ * Created by drfish on 6/8/2017. + */ +public class _150EvaluateReversePolishNotation { + public int evalRPN(String[] tokens) { + if (tokens == null) { + return 0; + } + Stack stack = new Stack<>(); + for (String token : tokens) { + switch (token) { + case "+": + stack.push(stack.pop() + stack.pop()); + break; + case "*": + stack.push(stack.pop() * stack.pop()); + break; + case "-": + int second = stack.pop(); + int first = stack.pop(); + stack.push(first - second); + break; + case "/": + second = stack.pop(); + first = stack.pop(); + stack.push(first / second); + break; + default: + stack.push(Integer.valueOf(token)); + } + } + return stack.pop(); + } + + public static void main(String[] args) { + _150EvaluateReversePolishNotation solution = new _150EvaluateReversePolishNotation(); + assert 9 == solution.evalRPN(new String[]{"2", "1", "+", "3", "*"}); + assert 6 == solution.evalRPN(new String[]{"4", "13", "5", "/", "+"}); + } +} From 46bee31e0a2c6800c79da6323bc986376464fce4 Mon Sep 17 00:00:00 2001 From: drfish Date: Thu, 8 Jun 2017 11:34:40 +0800 Subject: [PATCH 33/53] Java solution 155 && 173 --- java/_155MinStack.java | 69 ++++++++++++++++++++++++++ java/_173BinarySearchTreeIterator.java | 44 ++++++++++++++++ 2 files changed, 113 insertions(+) create mode 100644 java/_155MinStack.java create mode 100644 java/_173BinarySearchTreeIterator.java diff --git a/java/_155MinStack.java b/java/_155MinStack.java new file mode 100644 index 0000000..f08bfb5 --- /dev/null +++ b/java/_155MinStack.java @@ -0,0 +1,69 @@ +import java.util.Stack; + +/** + * Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. + *

+ * push(x) -- Push element x onto stack. + * pop() -- Removes the element on top of the stack. + * top() -- Get the top element. + * getMin() -- Retrieve the minimum element in the stack. + *

+ * Example: + * MinStack minStack = new MinStack(); + * minStack.push(-2); + * minStack.push(0); + * minStack.push(-3); + * minStack.getMin(); --> Returns -3. + * minStack.pop(); + * minStack.top(); --> Returns 0. + * minStack.getMin(); --> Returns -2. + *

+ * Created by drfish on 6/8/2017. + */ +public class _155MinStack { + public class MinStack { + Stack stack; + Stack minStack; + + /** + * initialize your data structure here. + */ + public MinStack() { + stack = new Stack<>(); + minStack = new Stack<>(); + } + + public void push(int x) { + stack.push(x); + if (minStack.isEmpty() || minStack.peek() >= x) { + minStack.push(x); + } + } + + public void pop() { + int x = stack.pop(); + if (x == minStack.peek()) { + minStack.pop(); + } + } + + public int top() { + return stack.peek(); + } + + public int getMin() { + return minStack.peek(); + } + } + + public static void main(String[] args) { + MinStack minStack = new _155MinStack().new MinStack(); + minStack.push(-2); + minStack.push(0); + minStack.push(-3); + assert -3 == minStack.getMin(); + minStack.pop(); + assert 0 == minStack.top(); + assert -2 == minStack.getMin(); + } +} diff --git a/java/_173BinarySearchTreeIterator.java b/java/_173BinarySearchTreeIterator.java new file mode 100644 index 0000000..4b4ca34 --- /dev/null +++ b/java/_173BinarySearchTreeIterator.java @@ -0,0 +1,44 @@ +import java.util.Stack; + +/** + * Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST. + * Calling next() will return the next smallest number in the BST. + *

+ * Note: next() and hasNext() should run in average O(1) time and uses O(h) memory, where h is the height of the tree. + *

+ * Credits: + * Special thanks to @ts for adding this problem and creating all test cases. + *

+ * Created by drfish on 6/8/2017. + */ +public class _173BinarySearchTreeIterator { + public class BSTIterator { + private Stack stack; + private TreeNode node; + + public BSTIterator(TreeNode root) { + stack = new Stack<>(); + node = root; + } + + /** + * @return whether we have a next smallest number + */ + public boolean hasNext() { + return node != null || !stack.isEmpty(); + } + + /** + * @return the next smallest number + */ + public int next() { + while (node != null) { + stack.push(node); + node = node.left; + } + TreeNode temp = stack.pop(); + node = temp.right; + return temp.val; + } + } +} From 67cbbd165f3a2934cdb04b3301fcb46d7811301f Mon Sep 17 00:00:00 2001 From: drfish Date: Thu, 8 Jun 2017 13:04:28 +0800 Subject: [PATCH 34/53] Java solution 224 && 225 --- java/_224BasicCalculator.java | 54 +++++++++++++++++++++ java/_225ImplementStackUsingQueues.java | 64 +++++++++++++++++++++++++ 2 files changed, 118 insertions(+) create mode 100644 java/_224BasicCalculator.java create mode 100644 java/_225ImplementStackUsingQueues.java diff --git a/java/_224BasicCalculator.java b/java/_224BasicCalculator.java new file mode 100644 index 0000000..0fba9f6 --- /dev/null +++ b/java/_224BasicCalculator.java @@ -0,0 +1,54 @@ +import java.util.Stack; + +/** + * Implement a basic calculator to evaluate a simple expression string. + * The expression string may contain open ( and closing parentheses ), the plus + or minus sign -, non-negative integers and empty spaces . + * You may assume that the given expression is always valid. + *

+ * Some examples: + * "1 + 1" = 2 + * " 2-1 + 2 " = 3 + * "(1+(4+5+2)-3)+(6+8)" = 23 + *

+ * Note: Do not use the eval built-in library function. + *

+ * Created by drfish on 6/8/2017. + */ +public class _224BasicCalculator { + + public int calculate(String s) { + int sign = 1; + int result = 0; + Stack stack = new Stack<>(); + + for (int i = 0; i < s.length(); i++) { + if (Character.isDigit(s.charAt(i))) { + int sum = s.charAt(i) - '0'; + while (i + 1 < s.length() && Character.isDigit(s.charAt(i + 1))) { + sum = sum * 10 + s.charAt(i + 1) - '0'; + i++; + } + result += sum * sign; + } else if (s.charAt(i) == '+') { + sign = 1; + } else if (s.charAt(i) == '-') { + sign = -1; + } else if (s.charAt(i) == '(') { + stack.push(result); + stack.push(sign); + result = 0; + sign = 1; + } else if (s.charAt(i) == ')') { + result = result * stack.pop() + stack.pop(); + } + } + return result; + } + + public static void main(String[] args) { + _224BasicCalculator solution = new _224BasicCalculator(); + assert 2 == solution.calculate("1 + 1"); + assert 3 == solution.calculate(" 2-1 + 2 "); + assert 23 == solution.calculate("(1+(4+5+2)-3)+(6+8)"); + } +} diff --git a/java/_225ImplementStackUsingQueues.java b/java/_225ImplementStackUsingQueues.java new file mode 100644 index 0000000..72932c0 --- /dev/null +++ b/java/_225ImplementStackUsingQueues.java @@ -0,0 +1,64 @@ +import java.util.LinkedList; +import java.util.Queue; + +/** + * Implement the following operations of a stack using queues. + *

+ * push(x) -- Push element x onto stack. + * pop() -- Removes the element on top of the stack. + * top() -- Get the top element. + * empty() -- Return whether the stack is empty. + *

+ * Notes: + * You must use only standard operations of a queue -- which means only push to back, peek/pop from front, size, and is empty operations are valid. + * Depending on your language, queue may not be supported natively. You may simulate a queue by using a list or deque (double-ended queue), as long as you use only standard operations of a queue. + * You may assume that all operations are valid (for example, no pop or top operations will be called on an empty stack). + *

+ * Credits: + * Special thanks to @jianchao.li.fighter for adding this problem and all test cases. + *

+ * Created by drfish on 6/8/2017. + */ +public class _225ImplementStackUsingQueues { + public class MyStack { + private Queue queue; + + /** + * Initialize your data structure here. + */ + public MyStack() { + queue = new LinkedList<>(); + } + + /** + * Push element x onto stack. + */ + public void push(int x) { + queue.add(x); + for (int i = 0; i < queue.size() - 1; i++) { + queue.add(queue.poll()); + } + } + + /** + * Removes the element on top of the stack and returns that element. + */ + public int pop() { + return queue.poll(); + } + + /** + * Get the top element. + */ + public int top() { + return queue.peek(); + } + + /** + * Returns whether the stack is empty. + */ + public boolean empty() { + return queue.isEmpty(); + } + } +} From 962ddbb0244c525a9d1947c545efafad42b7709a Mon Sep 17 00:00:00 2001 From: drfish Date: Thu, 8 Jun 2017 19:30:17 +0800 Subject: [PATCH 35/53] Java solution 232 && 316 --- java/_232ImplementQueueUsingStacks.java | 70 +++++++++++++++++++++++++ java/_316RemoveDuplicateLetters.java | 55 +++++++++++++++++++ 2 files changed, 125 insertions(+) create mode 100644 java/_232ImplementQueueUsingStacks.java create mode 100644 java/_316RemoveDuplicateLetters.java diff --git a/java/_232ImplementQueueUsingStacks.java b/java/_232ImplementQueueUsingStacks.java new file mode 100644 index 0000000..bd3f5c4 --- /dev/null +++ b/java/_232ImplementQueueUsingStacks.java @@ -0,0 +1,70 @@ +import java.util.Stack; + +/** + * Implement the following operations of a queue using stacks. + *

+ * push(x) -- Push element x to the back of queue. + * pop() -- Removes the element from in front of queue. + * peek() -- Get the front element. + * empty() -- Return whether the queue is empty. + *

+ * Notes: + * You must use only standard operations of a stack -- which means only push to top, peek/pop from top, size, and is empty operations are valid. + * Depending on your language, stack may not be supported natively. You may simulate a stack by using a list or deque (double-ended queue), as long as you use only standard operations of a stack. + * You may assume that all operations are valid (for example, no pop or peek operations will be called on an empty queue). + *

+ * Created by drfish on 6/8/2017. + */ +public class _232ImplementQueueUsingStacks { + public class MyQueue { + private Stack stack1; + private Stack stack2; + + /** + * Initialize your data structure here. + */ + public MyQueue() { + stack1 = new Stack<>(); + stack2 = new Stack<>(); + } + + /** + * Push element x to the back of queue. + */ + public void push(int x) { + stack1.push(x); + } + + /** + * Removes the element from in front of queue and returns that element. + */ + public int pop() { + if (stack2.isEmpty()) { + while (!stack1.isEmpty()) { + stack2.push(stack1.pop()); + } + } + return stack2.pop(); + + } + + /** + * Get the front element. + */ + public int peek() { + if (stack2.isEmpty()) { + while (!stack1.isEmpty()) { + stack2.push(stack1.pop()); + } + } + return stack2.peek(); + } + + /** + * Returns whether the queue is empty. + */ + public boolean empty() { + return stack1.isEmpty() && stack2.isEmpty(); + } + } +} diff --git a/java/_316RemoveDuplicateLetters.java b/java/_316RemoveDuplicateLetters.java new file mode 100644 index 0000000..fb087c0 --- /dev/null +++ b/java/_316RemoveDuplicateLetters.java @@ -0,0 +1,55 @@ +import java.util.Stack; + +/** + * Given a string which contains only lowercase letters, remove duplicate letters so that every letter appear once and only once. You must make sure your result is the smallest in lexicographical order among all possible results. + *

+ * Example: + * Given "bcabc" + * Return "abc" + *

+ * Given "cbacdcbc" + * Return "acdb" + *

+ * Credits: + * Special thanks to @dietpepsi for adding this problem and creating all test cases. + *

+ * Created by drfish on 6/8/2017. + */ +public class _316RemoveDuplicateLetters { + public String removeDuplicateLetters(String s) { + if (s == null) { + return null; + } + int[] count = new int[26]; + boolean[] visited = new boolean[26]; + char[] chars = s.toCharArray(); + for (char c : chars) { + count[c - 'a']++; + } + Stack stack = new Stack<>(); + int index; + for (char c : chars) { + index = c - 'a'; + count[index]--; + if (visited[index]) { + continue; + } + while (!stack.isEmpty() && c < stack.peek() && count[stack.peek() - 'a'] != 0) { + visited[stack.pop() - 'a'] = false; + } + stack.push(c); + visited[index] = true; + } + StringBuilder sb = new StringBuilder(); + while (!stack.isEmpty()) { + sb.insert(0, stack.pop()); + } + return sb.toString(); + } + + public static void main(String[] args) { + _316RemoveDuplicateLetters solution = new _316RemoveDuplicateLetters(); + assert "abc".equals(solution.removeDuplicateLetters("bcabc")); + assert "acdb".equals(solution.removeDuplicateLetters("cbacdcbc")); + } +} From e89b8dace48a170b2fd8d79fe032d4cbc01d2a9c Mon Sep 17 00:00:00 2001 From: drfish Date: Fri, 9 Jun 2017 09:35:54 +0800 Subject: [PATCH 36/53] Java solution 331 && 341 --- ...ifyPreorderSerializationOfABinaryTree.java | 58 ++++++++++++++++ java/_341FlattenNestedListIterator.java | 67 +++++++++++++++++++ 2 files changed, 125 insertions(+) create mode 100644 java/_331VerifyPreorderSerializationOfABinaryTree.java create mode 100644 java/_341FlattenNestedListIterator.java diff --git a/java/_331VerifyPreorderSerializationOfABinaryTree.java b/java/_331VerifyPreorderSerializationOfABinaryTree.java new file mode 100644 index 0000000..59c9723 --- /dev/null +++ b/java/_331VerifyPreorderSerializationOfABinaryTree.java @@ -0,0 +1,58 @@ +import java.util.Stack; + +/** + * One way to serialize a binary tree is to use pre-order traversal. When we encounter a non-null node, we record the node's value. If it is a null node, we record using a sentinel value such as #. + *

+ * _9_ + * / \ + * 3 2 + * / \ / \ + * 4 1 # 6 + * / \ / \ / \ + * # # # # # # + * For example, the above binary tree can be serialized to the string "9,3,4,#,#,1,#,#,2,#,6,#,#", where # represents a null node. + * Given a string of comma separated values, verify whether it is a correct preorder traversal serialization of a binary tree. Find an algorithm without reconstructing the tree. + * Each comma separated value in the string must be either an integer or a character '#' representing null pointer. + * You may assume that the input format is always valid, for example it could never contain two consecutive commas such as "1,,3". + *

+ * Example 1: + * "9,3,4,#,#,1,#,#,2,#,6,#,#" + * Return true + *

+ * Example 2: + * "1,#" + * Return false + *

+ * Example 3: + * "9,#,#,1" + * Return false + *

+ * Credits: + * Special thanks to @dietpepsi for adding this problem and creating all test cases. + *

+ * Created by drfish on 6/9/2017. + */ +public class _331VerifyPreorderSerializationOfABinaryTree { + public boolean isValidSerialization(String preorder) { + Stack stack = new Stack<>(); + String[] splits = preorder.split(","); + for (String s : splits) { + while (s.equals("#") && !stack.isEmpty() && stack.peek().equals("#")) { + stack.pop(); + if (stack.isEmpty()) { + return false; + } + stack.pop(); + } + stack.push(s); + } + return stack.size() == 1 && stack.peek().equals("#"); + } + + public static void main(String[] args) { + _331VerifyPreorderSerializationOfABinaryTree solution = new _331VerifyPreorderSerializationOfABinaryTree(); + assert solution.isValidSerialization("9,3,4,#,#,1,#,#,2,#,6,#,#"); + assert !solution.isValidSerialization("1,#"); + assert !solution.isValidSerialization("9,#,#,1"); + } +} diff --git a/java/_341FlattenNestedListIterator.java b/java/_341FlattenNestedListIterator.java new file mode 100644 index 0000000..3e20df0 --- /dev/null +++ b/java/_341FlattenNestedListIterator.java @@ -0,0 +1,67 @@ +import java.util.Iterator; +import java.util.List; +import java.util.Stack; + +/** + * Given a nested list of integers, implement an iterator to flatten it. + * Each element is either an integer, or a list -- whose elements may also be integers or other lists. + *

+ * Example 1: + * Given the list [[1,1],2,[1,1]], + * By calling next repeatedly until hasNext returns false, the order of elements returned by next should be: [1,1,2,1,1]. + *

+ * Example 2: + * Given the list [1,[4,[6]]], + * By calling next repeatedly until hasNext returns false, the order of elements returned by next should be: [1,4,6]. + *

+ * Created by drfish on 6/9/2017. + */ +public class _341FlattenNestedListIterator { + /** + * // This is the interface that allows for creating nested lists. + * // You should not implement it, or speculate about its implementation + **/ + public interface NestedInteger { + + // @return true if this NestedInteger holds a single integer, rather than a nested list. + public boolean isInteger(); + + // @return the single integer that this NestedInteger holds, if it holds a single integer + // Return null if this NestedInteger holds a nested list + public Integer getInteger(); + + // @return the nested list that this NestedInteger holds, if it holds a nested list + // Return null if this NestedInteger holds a single integer + public List getList(); + } + + public class NestedIterator implements Iterator { + Stack stack = new Stack<>(); + + public NestedIterator(List nestedList) { + for (int i = nestedList.size() - 1; i >= 0; i--) { + stack.push(nestedList.get(i)); + } + } + + @Override + public Integer next() { + return stack.pop().getInteger(); + } + + @Override + public boolean hasNext() { + while (!stack.isEmpty()) { + NestedInteger curr = stack.peek(); + if (curr.isInteger()) { + return true; + } + stack.pop(); + for (int i = curr.getList().size() - 1; i >= 0; i--) { + stack.push(curr.getList().get(i)); + } + } + return false; + } + } +} From a2268cf4adf5b20600b3b052400b874748dfc3df Mon Sep 17 00:00:00 2001 From: Shen Jie Date: Mon, 12 Jun 2017 23:42:44 +0800 Subject: [PATCH 37/53] Java solution 215 && 239 --- java/_215KthLargestElementInAnArray.java | 37 ++++++++++++++++ java/_239SlidingWindowMaximum.java | 54 ++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 java/_215KthLargestElementInAnArray.java create mode 100644 java/_239SlidingWindowMaximum.java diff --git a/java/_215KthLargestElementInAnArray.java b/java/_215KthLargestElementInAnArray.java new file mode 100644 index 0000000..1e3c464 --- /dev/null +++ b/java/_215KthLargestElementInAnArray.java @@ -0,0 +1,37 @@ +import java.util.PriorityQueue; + +/** + * Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, + * not the kth distinct element. + *

+ * For example, + * Given [3,2,1,5,6,4] and k = 2, return 5. + *

+ * Note: + * You may assume k is always valid, 1 ≤ k ≤ array's length. + *

+ * Credits: + * Special thanks to @mithmatt for adding this problem and creating all test cases. + *

+ * Created by drfish on 10/06/2017. + */ +public class _215KthLargestElementInAnArray { + /** + * heap solution + */ + public int findKthLargest(int[] nums, int k) { + PriorityQueue heap = new PriorityQueue<>(); + for (int num : nums) { + heap.offer(num); + if (heap.size() > k) { + heap.poll(); + } + } + return heap.peek(); + } + + public static void main(String[] args) { + _215KthLargestElementInAnArray solution = new _215KthLargestElementInAnArray(); + assert 5 == solution.findKthLargest(new int[]{3, 2, 1, 5, 6, 4}, 2); + } +} diff --git a/java/_239SlidingWindowMaximum.java b/java/_239SlidingWindowMaximum.java new file mode 100644 index 0000000..8b9a108 --- /dev/null +++ b/java/_239SlidingWindowMaximum.java @@ -0,0 +1,54 @@ +import java.util.Arrays; + +/** + * Given an array nums, there is a sliding window of size k which is moving from the very left of the array to the + * very right. You can only see the k numbers in the window. Each time the sliding window moves right by one position. + *

+ * For example, + * Given nums = [1,3,-1,-3,5,3,6,7], and k = 3. + *

+ * Window position Max + * --------------- ----- + * [1 3 -1] -3 5 3 6 7 3 + * 1 [3 -1 -3] 5 3 6 7 3 + * 1 3 [-1 -3 5] 3 6 7 5 + * 1 3 -1 [-3 5 3] 6 7 5 + * 1 3 -1 -3 [5 3 6] 7 6 + * 1 3 -1 -3 5 [3 6 7] 7 + * Therefore, return the max sliding window as [3,3,5,5,6,7]. + *

+ * Note: + * You may assume k is always valid, ie: 1 ≤ k ≤ input array's size for non-empty array. + *

+ * Follow up: + * Could you solve it in linear time? + *

+ * Created by drfish on 12/06/2017. + */ +public class _239SlidingWindowMaximum { + public int[] maxSlidingWindow(int[] nums, int k) { + if (nums == null || nums.length < 1) { + return new int[0]; + } + int[] leftMax = new int[nums.length]; + int[] rightMax = new int[nums.length]; + leftMax[0] = nums[0]; + rightMax[nums.length - 1] = nums[nums.length - 1]; + for (int i = 1; i < nums.length; i++) { + leftMax[i] = (i % k == 0) ? nums[i] : Math.max(leftMax[i - 1], nums[i]); + int j = nums.length - i - 1; + rightMax[j] = (j % k == 0) ? nums[j] : Math.max(rightMax[j + 1], nums[j]); + } + int[] result = new int[nums.length - k + 1]; + for (int i = 0; i + k <= nums.length; i++) { + result[i] = Math.max(leftMax[i + k - 1], rightMax[i]); + } + return result; + } + + public static void main(String[] args) { + _239SlidingWindowMaximum solution = new _239SlidingWindowMaximum(); + assert Arrays.equals(new int[]{3, 3, 5, 5, 6, 7}, solution.maxSlidingWindow(new int[]{1, 3, -1, -3, 5, 3, 6, + 7}, 3)); + } +} From 1fdb5d9251c0192a72b93e74132caba248c4b56a Mon Sep 17 00:00:00 2001 From: drfish Date: Tue, 13 Jun 2017 09:30:15 +0800 Subject: [PATCH 38/53] Java solution 71 && 385 --- java/_071SimplifyPath.java | 56 +++++++++++++++ java/_385MiniParser.java | 135 +++++++++++++++++++++++++++++++++++++ 2 files changed, 191 insertions(+) create mode 100644 java/_071SimplifyPath.java create mode 100644 java/_385MiniParser.java diff --git a/java/_071SimplifyPath.java b/java/_071SimplifyPath.java new file mode 100644 index 0000000..119c190 --- /dev/null +++ b/java/_071SimplifyPath.java @@ -0,0 +1,56 @@ +import java.util.Arrays; +import java.util.Stack; + +/** + * Given an absolute path for a file (Unix-style), simplify it. + *

+ * For example, + * path = "/home/", => "/home" + * path = "/a/./b/../../c/", => "/c" + * click to show corner cases. + *

+ * Corner Cases: + * Did you consider the case where path = "/../"? + * In this case, you should return "/". + * Another corner case is the path might contain multiple slashes '/' together, such as "/home//foo/". + * In this case, you should ignore redundant slashes and return "/home/foo". + *

+ * Created by drfish on 6/7/2017. + */ +public class _071SimplifyPath { + public String simplifyPath(String path) { + if (path == null) { + return ""; + } + String[] parts = path.split("/"); + Stack stack = new Stack<>(); + for (String part : parts) { + switch (part) { + case ".": + break; + case "": + break; + case "..": + if (!stack.isEmpty()) { + stack.pop(); + } + break; + default: + stack.push(part); + } + } + + String result = ""; + for (String s : stack) { + result += "/" + s; + } + return result.length() == 0 ? "/" : result; + } + + public static void main(String[] args) { + _071SimplifyPath solution = new _071SimplifyPath(); + assert "/home".equals(solution.simplifyPath("/home/")); + assert "/c".equals(solution.simplifyPath("/a/./b/../../c/")); + assert "/".equals(solution.simplifyPath("/home/../../..")); + } +} diff --git a/java/_385MiniParser.java b/java/_385MiniParser.java new file mode 100644 index 0000000..cd86699 --- /dev/null +++ b/java/_385MiniParser.java @@ -0,0 +1,135 @@ +import java.util.List; +import java.util.Stack; + +/** + * Given a nested list of integers represented as a string, implement a parser to deserialize it. + * Each element is either an integer, or a list -- whose elements may also be integers or other lists. + *

+ * Note: You may assume that the string is well-formed: + * String is non-empty. + * String does not contain white spaces. + * String contains only digits 0-9, [, - ,, ]. + *

+ * Example 1: + * Given s = "324", + * You should return a NestedInteger object which contains a single integer 324. + *

+ * Example 2: + * Given s = "[123,[456,[789]]]", + * Return a NestedInteger object containing a nested list with 2 elements: + *

+ * 1. An integer containing value 123. + * 2. A nested list containing two elements: + * i. An integer containing value 456. + * ii. A nested list with one element: + * a. An integer containing value 789. + *

+ * Created by drfish on 6/9/2017. + */ +public class _385MiniParser { + /** + * // This is the interface that allows for creating nested lists. + * // You should not implement it, or speculate about its implementation + **/ + public interface INestedInteger { +// // Constructor initializes an empty nested list. +// public NestedInteger(); +// +// // Constructor initializes a single integer. +// public NestedInteger(int value); + + // @return true if this NestedInteger holds a single integer, rather than a nested list. + public boolean isInteger(); + + // @return the single integer that this NestedInteger holds, if it holds a single integer + // Return null if this NestedInteger holds a nested list + public Integer getInteger(); + + // Set this NestedInteger to hold a single integer. + public void setInteger(int value); + + // Set this NestedInteger to hold a nested list and adds a nested integer to it. + public void add(NestedInteger ni); + + // @return the nested list that this NestedInteger holds, if it holds a nested list + // Return null if this NestedInteger holds a single integer + public List getList(); + } + + public class NestedInteger implements INestedInteger { + public NestedInteger() { + + } + + public NestedInteger(int value) { + + } + + @Override + public boolean isInteger() { + return false; + } + + @Override + public Integer getInteger() { + return null; + } + + @Override + public void setInteger(int value) { + + } + + @Override + public void add(NestedInteger ni) { + + } + + @Override + public List getList() { + return null; + } + } + + public class Solution { + public NestedInteger deserialize(String s) { + if (s == null || s.isEmpty()) { + return null; + } + if (s.charAt(0) != '[') { + return new NestedInteger(Integer.valueOf(s)); + } + Stack stack = new Stack<>(); + int start = 0; + NestedInteger curr = null; + for (int i = 0; i < s.length(); i++) { + char c = s.charAt(i); + if (c == '[') { + if (curr != null) { + stack.push(curr); + } + curr = new NestedInteger(); + start = i + 1; + } else if (c == ']') { + String num = s.substring(start, i); + if (!num.isEmpty()) { + curr.add(new NestedInteger(Integer.valueOf(num))); + } + if (!stack.isEmpty()) { + NestedInteger top = stack.pop(); + top.add(curr); + curr = top; + } + start = i + 1; + } else if (c == ',') { + if (s.charAt(i - 1) != ']') { + String num = s.substring(start, i); + curr.add(new NestedInteger(Integer.valueOf(num))); + } + start = i + 1; + } + } + return curr; + } + } +} From 36890ecf929f570131b5840a9f55c659a9c64923 Mon Sep 17 00:00:00 2001 From: drfish Date: Tue, 13 Jun 2017 10:51:50 +0800 Subject: [PATCH 39/53] Java solution 394 && 402 --- java/_394DecodeString.java | 55 +++++++++++++++++++++++++++++++ java/_402RemoveKDigits.java | 66 +++++++++++++++++++++++++++++++++++++ 2 files changed, 121 insertions(+) create mode 100644 java/_394DecodeString.java create mode 100644 java/_402RemoveKDigits.java diff --git a/java/_394DecodeString.java b/java/_394DecodeString.java new file mode 100644 index 0000000..fdfca04 --- /dev/null +++ b/java/_394DecodeString.java @@ -0,0 +1,55 @@ +import java.util.Stack; + +/** + * Given an encoded string, return it's decoded string. + * The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times. Note that k is guaranteed to be a positive integer. + * You may assume that the input string is always valid; No extra white spaces, square brackets are well-formed, etc. + * Furthermore, you may assume that the original data does not contain any digits and that digits are only for those repeat numbers, k. For example, there won't be input like 3a or 2[4]. + *

+ * Examples: + *

+ * s = "3[a]2[bc]", return "aaabcbc". + * s = "3[a2[c]]", return "accaccacc". + * s = "2[abc]3[cd]ef", return "abcabccdcdcdef". + *

+ * Created by drfish on 6/13/2017. + */ +public class _394DecodeString { + public String decodeString(String s) { + Stack countStack = new Stack<>(); + Stack stringStack = new Stack<>(); + int index = 0; + String curr = ""; + while (index < s.length()) { + char c = s.charAt(index); + if (Character.isDigit(c)) { + int start = index; + while (Character.isDigit(s.charAt(index + 1))) { + index++; + } + countStack.push(Integer.parseInt(s.substring(start, index + 1))); + } else if (c == '[') { + stringStack.push(curr); + curr = ""; + } else if (c == ']') { + StringBuilder sb = new StringBuilder(stringStack.pop()); + int repeatTimes = countStack.pop(); + for (int i = 0; i < repeatTimes; i++) { + sb.append(curr); + } + curr = sb.toString(); + } else { + curr += c; + } + index++; + } + return curr; + } + + public static void main(String[] args) { + _394DecodeString solution = new _394DecodeString(); + assert "aaabcbc".equals(solution.decodeString("3[a]2[bc]")); + assert "accaccacc".equals(solution.decodeString("3[a2[c]]")); + assert "abcabccdcdcdef".equals(solution.decodeString("2[abc]3[cd]ef")); + } +} diff --git a/java/_402RemoveKDigits.java b/java/_402RemoveKDigits.java new file mode 100644 index 0000000..f1bb06b --- /dev/null +++ b/java/_402RemoveKDigits.java @@ -0,0 +1,66 @@ +import java.util.Stack; + +/** + * Given a non-negative integer num represented as a string, remove k digits from the number so that the new number is the smallest possible. + *

+ * Note: + * The length of num is less than 10002 and will be ≥ k. + * The given num does not contain any leading zero. + *

+ * Example 1: + * Input: num = "1432219", k = 3 + * Output: "1219" + * Explanation: Remove the three digits 4, 3, and 2 to form the new number 1219 which is the smallest. + *

+ * Example 2: + * Input: num = "10200", k = 1 + * Output: "200" + * Explanation: Remove the leading 1 and the number is 200. Note that the output must not contain leading zeroes. + *

+ * Example 3: + * Input: num = "10", k = 2 + * Output: "0" + * Explanation: Remove all the digits from the number and it is left with nothing which is 0. + *

+ * Created by drfish on 6/13/2017. + */ +public class _402RemoveKDigits { + public String removeKdigits(String num, int k) { + if (num.length() <= k) { + return "0"; + } + Stack stack = new Stack<>(); + int index = 0; + // remove digit which is bigger than its next one + while (index < num.length()) { + while (k > 0 && !stack.isEmpty() && stack.peek() > num.charAt(index)) { + stack.pop(); + k--; + } + stack.push(num.charAt(index)); + index++; + } + while (k > 0) { + stack.pop(); + k--; + } + // construct new number + StringBuilder sb = new StringBuilder(); + while (!stack.isEmpty()) { + sb.append(stack.pop()); + } + sb.reverse(); + // remove zeros at the head + while (sb.length() > 0 && sb.charAt(0) == '0') { + sb.deleteCharAt(0); + } + return sb.toString(); + } + + public static void main(String[] args) { + _402RemoveKDigits solution = new _402RemoveKDigits(); + assert "1219".equals(solution.removeKdigits("1432219", 3)); + assert "200".equals(solution.removeKdigits("10200", 1)); + assert "0".equals(solution.removeKdigits("10", 2)); + } +} From 7c1365c5e90b07da2985af5b1db57fc6adb90401 Mon Sep 17 00:00:00 2001 From: drfish Date: Tue, 13 Jun 2017 10:56:44 +0800 Subject: [PATCH 40/53] Fix boundary check bug for java 402 --- java/_402RemoveKDigits.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/_402RemoveKDigits.java b/java/_402RemoveKDigits.java index f1bb06b..8acd991 100644 --- a/java/_402RemoveKDigits.java +++ b/java/_402RemoveKDigits.java @@ -51,7 +51,7 @@ public String removeKdigits(String num, int k) { } sb.reverse(); // remove zeros at the head - while (sb.length() > 0 && sb.charAt(0) == '0') { + while (sb.length() > 1 && sb.charAt(0) == '0') { sb.deleteCharAt(0); } return sb.toString(); From 3df27d940c8422e85fcfd2b05b14cc9a0421a061 Mon Sep 17 00:00:00 2001 From: Shen Jie Date: Tue, 13 Jun 2017 23:31:51 +0800 Subject: [PATCH 41/53] Java solution 264 && 295 --- java/_264UglyNumberII.java | 38 ++++++++++++++++ java/_295FindMedianFromDataStream.java | 60 ++++++++++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 java/_264UglyNumberII.java create mode 100644 java/_295FindMedianFromDataStream.java diff --git a/java/_264UglyNumberII.java b/java/_264UglyNumberII.java new file mode 100644 index 0000000..99bc683 --- /dev/null +++ b/java/_264UglyNumberII.java @@ -0,0 +1,38 @@ +/** + * Write a program to find the n-th ugly number. + * Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 1, 2, 3, 4, 5, 6, 8, 9, + * 10, 12 is the sequence of the first 10 ugly numbers. + *

+ * Note that 1 is typically treated as an ugly number, and n does not exceed 1690. + *

+ * Credits: + * Special thanks to @jianchao.li.fighter for adding this problem and creating all test cases. + *

+ * Created by drfish on 12/06/2017. + */ +public class _264UglyNumberII { + public int nthUglyNumber(int n) { + int index2 = 0, index3 = 0, index5 = 0; + int[] dp = new int[n]; + dp[0] = 1; + for (int i = 1; i < n; i++) { + dp[i] = Math.min(dp[index2] * 2, Math.min(dp[index3] * 3, dp[index5] * 5)); + if (dp[i] == dp[index2] * 2) { + index2++; + } + if (dp[i] == dp[index3] * 3) { + index3++; + } + if (dp[i] == dp[index5] * 5) { + index5++; + } + } + return dp[n - 1]; + } + + public static void main(String[] args) { + _264UglyNumberII solution = new _264UglyNumberII(); + assert 1 == solution.nthUglyNumber(1); + assert 12 == solution.nthUglyNumber(10); + } +} diff --git a/java/_295FindMedianFromDataStream.java b/java/_295FindMedianFromDataStream.java new file mode 100644 index 0000000..d683e9a --- /dev/null +++ b/java/_295FindMedianFromDataStream.java @@ -0,0 +1,60 @@ +import java.util.PriorityQueue; + +/** + * Median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. + * So the median is the mean of the two middle value. + *

+ * Examples: + * [2,3,4] , the median is 3 + * [2,3], the median is (2 + 3) / 2 = 2.5 + *

+ * Design a data structure that supports the following two operations: + * void addNum(int num) - Add a integer number from the data stream to the data structure. + * double findMedian() - Return the median of all elements so far. + *

+ * For example: + * addNum(1) + * addNum(2) + * findMedian() -> 1.5 + * addNum(3) + * findMedian() -> 2 + *

+ * Credits: + * Special thanks to @Louis1992 for adding this problem and creating all test cases. + *

+ * Created by drfish on 13/06/2017. + */ +public class _295FindMedianFromDataStream { + public class MedianFinder { + private PriorityQueue minHeap; + private PriorityQueue maxHeap; + private boolean isEven = true; + + /** + * initialize your data structure here. + */ + public MedianFinder() { + minHeap = new PriorityQueue<>(); + maxHeap = new PriorityQueue<>((n1, n2) -> n2 - n1); + } + + public void addNum(int num) { + if (isEven) { + minHeap.offer(num); + maxHeap.offer(minHeap.poll()); + } else { + maxHeap.offer(num); + minHeap.offer(maxHeap.poll()); + } + isEven = !isEven; + } + + public double findMedian() { + if (isEven) { + return (maxHeap.peek() + minHeap.peek()) / 2.0; + } else { + return maxHeap.peek(); + } + } + } +} From 33c00eb54c13836970b69a5285db1e3bdffd3a2b Mon Sep 17 00:00:00 2001 From: drfish Date: Thu, 15 Jun 2017 10:28:51 +0800 Subject: [PATCH 42/53] Java solution 456 && 496 --- java/_456132Pattern.java | 47 ++++++++++++++++++++++++++ java/_496NextGreaterElementI.java | 55 +++++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+) create mode 100644 java/_456132Pattern.java create mode 100644 java/_496NextGreaterElementI.java diff --git a/java/_456132Pattern.java b/java/_456132Pattern.java new file mode 100644 index 0000000..7ef3c06 --- /dev/null +++ b/java/_456132Pattern.java @@ -0,0 +1,47 @@ +import java.util.Stack; + +/** + * Given a sequence of n integers a1, a2, ..., an, a 132 pattern is a subsequence ai, aj, ak such that i < j < k and ai < ak < aj. Design an algorithm that takes a list of n numbers as input and checks whether there is a 132 pattern in the list. + *

+ * Note: n will be less than 15,000. + *

+ * Example 1: + * Input: [1, 2, 3, 4] + * Output: False + * Explanation: There is no 132 pattern in the sequence. + *

+ * Example 2: + * Input: [3, 1, 4, 2] + * Output: True + * Explanation: There is a 132 pattern in the sequence: [1, 4, 2]. + *

+ * Example 3: + * Input: [-1, 3, 2, 0] + * Output: True + * Explanation: There are three 132 patterns in the sequence: [-1, 3, 2], [-1, 3, 0] and [-1, 2, 0]. + *

+ * Created by drfish on 6/13/2017. + */ +public class _456132Pattern { + public boolean find132pattern(int[] nums) { + int num3 = Integer.MIN_VALUE; + Stack stack = new Stack<>(); + for (int i = nums.length - 1; i >= 0; i--) { + if (nums[i] < num3) { + return true; + // always track the largest third num + } else while (!stack.isEmpty() && nums[i] > stack.peek()) { + num3 = stack.pop(); + } + stack.push(nums[i]); + } + return false; + } + + public static void main(String[] args) { + _456132Pattern solution = new _456132Pattern(); + assert !solution.find132pattern(new int[]{1, 2, 3, 4}); + assert solution.find132pattern(new int[]{3, 1, 4, 2}); + assert solution.find132pattern(new int[]{-1, 3, 2, 0}); + } +} diff --git a/java/_496NextGreaterElementI.java b/java/_496NextGreaterElementI.java new file mode 100644 index 0000000..590d2ec --- /dev/null +++ b/java/_496NextGreaterElementI.java @@ -0,0 +1,55 @@ +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.Stack; + +/** + * You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next greater numbers for nums1's elements in the corresponding places of nums2. + * The Next Greater Number of a number x in nums1 is the first greater number to its right in nums2. If it does not exist, output -1 for this number. + *

+ * Example 1: + * Input: nums1 = [4,1,2], nums2 = [1,3,4,2]. + * Output: [-1,3,-1] + * Explanation: + * For number 4 in the first array, you cannot find the next greater number for it in the second array, so output -1. + * For number 1 in the first array, the next greater number for it in the second array is 3. + * For number 2 in the first array, there is no next greater number for it in the second array, so output -1. + *

+ * Example 2: + * Input: nums1 = [2,4], nums2 = [1,2,3,4]. + * Output: [3,-1] + * Explanation: + * For number 2 in the first array, the next greater number for it in the second array is 3. + * For number 4 in the first array, there is no next greater number for it in the second array, so output -1. + *

+ * Note: + * All elements in nums1 and nums2 are unique. + * The length of both nums1 and nums2 would not exceed 1000. + *

+ * Created by drfish on 6/14/2017. + */ +public class _496NextGreaterElementI { + public int[] nextGreaterElement(int[] findNums, int[] nums) { + Map map = new HashMap<>(); + Stack stack = new Stack<>(); + + for (int num : nums) { + while (!stack.isEmpty() && num > stack.peek()) { + map.put(stack.pop(), num); + } + stack.push(num); + } + + int[] result = new int[findNums.length]; + for (int i = 0; i < findNums.length; i++) { + result[i] = map.getOrDefault(findNums[i], -1); + } + return result; + } + + public static void main(String[] args) { + _496NextGreaterElementI solution = new _496NextGreaterElementI(); + assert Arrays.equals(new int[]{-1, 3, -1}, solution.nextGreaterElement(new int[]{4, 1, 2}, new int[]{1, 3, 4, 2})); + assert Arrays.equals(new int[]{3, -1}, solution.nextGreaterElement(new int[]{2, 4}, new int[]{1, 2, 3, 4})); + } +} From f8b61615751cd1d1a1e8dec97c1eb470b943773f Mon Sep 17 00:00:00 2001 From: Shen Jie Date: Thu, 15 Jun 2017 23:52:36 +0800 Subject: [PATCH 43/53] Java solution 347 --- java/_347TopKFrequentElements.java | 38 ++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 java/_347TopKFrequentElements.java diff --git a/java/_347TopKFrequentElements.java b/java/_347TopKFrequentElements.java new file mode 100644 index 0000000..86fd30d --- /dev/null +++ b/java/_347TopKFrequentElements.java @@ -0,0 +1,38 @@ +import java.util.*; + +/** + * Given a non-empty array of integers, return the k most frequent elements. + *

+ * For example, + * Given [1,1,1,2,2,3] and k = 2, return [1,2]. + *

+ * Note: + * You may assume k is always valid, 1 ≤ k ≤ number of unique elements. + * Your algorithm's time complexity must be better than O(n log n), where n is the array's size. + *

+ * Created by drfish on 15/06/2017. + */ +public class _347TopKFrequentElements { + public List topKFrequent(int[] nums, int k) { + List result = new ArrayList<>(); + Map map = new HashMap<>(); + PriorityQueue> maxHeap = new PriorityQueue<>((n1, n2) -> n2.getValue() - + n1.getValue()); + for (int num : nums) { + map.put(num, map.getOrDefault(num, 0) + 1); + } + for (Map.Entry entry : map.entrySet()) { + maxHeap.offer(entry); + } + while (k > 0) { + k--; + result.add(maxHeap.poll().getKey()); + } + return result; + } + + public static void main(String[] args) { + _347TopKFrequentElements solution = new _347TopKFrequentElements(); + assert Arrays.asList(1, 2).equals(solution.topKFrequent(new int[]{1, 1, 1, 2, 2, 3}, 2)); + } +} From f483351ae70fedde3b1549a78b4b759dcdcb0acc Mon Sep 17 00:00:00 2001 From: Shen Jie Date: Sun, 18 Jun 2017 23:02:28 +0800 Subject: [PATCH 44/53] Java solution 313 --- java/_313SuperUglyNumber.java | 43 +++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 java/_313SuperUglyNumber.java diff --git a/java/_313SuperUglyNumber.java b/java/_313SuperUglyNumber.java new file mode 100644 index 0000000..2933dcf --- /dev/null +++ b/java/_313SuperUglyNumber.java @@ -0,0 +1,43 @@ +/** + * Write a program to find the nth super ugly number. + *

+ * Super ugly numbers are positive numbers whose all prime factors are in the given prime list primes of size k. For + * example, [1, 2, 4, 7, 8, 13, 14, 16, 19, 26, 28, 32] is the sequence of the first 12 super ugly numbers given + * primes = [2, 7, 13, 19] of size 4. + *

+ * Note: + * (1) 1 is a super ugly number for any given primes. + * (2) The given numbers in primes are in ascending order. + * (3) 0 < k ≤ 100, 0 < n ≤ 106, 0 < primes[i] < 1000. + * (4) The nth super ugly number is guaranteed to fit in a 32-bit signed integer. + *

+ * Credits: + * Special thanks to @dietpepsi for adding this problem and creating all test cases. + *

+ * Created by drfish on 16/06/2017. + */ +public class _313SuperUglyNumber { + public int nthSuperUglyNumber(int n, int[] primes) { + int[] indexes = new int[primes.length]; + int[] superUgly = new int[n]; + + superUgly[0] = 1; + for (int i = 1; i < n; i++) { + superUgly[i] = Integer.MAX_VALUE; + for (int j = 0; j < primes.length; j++) { + superUgly[i] = Math.min(superUgly[i], primes[j] * superUgly[indexes[j]]); + } + for (int j = 0; j < primes.length; j++) { + while (primes[j] * superUgly[indexes[j]] <= superUgly[i]) { + indexes[j]++; + } + } + } + return superUgly[n - 1]; + } + + public static void main(String[] args) { + _313SuperUglyNumber solution = new _313SuperUglyNumber(); + assert 32 == solution.nthSuperUglyNumber(12, new int[]{2, 7, 13, 19}); + } +} From 8634d8adba5bba8469016216cfb72aae0bfe12cf Mon Sep 17 00:00:00 2001 From: drfish Date: Thu, 22 Jun 2017 11:23:48 +0800 Subject: [PATCH 45/53] Java solution 18 --- java/_0184Sum.java | 70 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 java/_0184Sum.java diff --git a/java/_0184Sum.java b/java/_0184Sum.java new file mode 100644 index 0000000..3e6a949 --- /dev/null +++ b/java/_0184Sum.java @@ -0,0 +1,70 @@ +import java.util.*; + +/** + * Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target. + *

+ * Note: The solution set must not contain duplicate quadruplets. + *

+ * For example, given array S = [1, 0, -1, 0, -2, 2], and target = 0. + * A solution set is: + * [ + * [-1, 0, 0, 1], + * [-2, -1, 1, 2], + * [-2, 0, 0, 2] + * ] + *

+ * Created by drfish on 6/20/2017. + */ +public class _0184Sum { + public List> fourSum(int[] nums, int target) { + List> result = new ArrayList<>(); + if (nums.length < 4) { + return result; + } + Arrays.sort(nums); + for (int i = 0; i < nums.length - 3; i++) { + if (nums[i] + nums[i + 1] + nums[i + 2] + nums[i + 3] > target) { + break; + } + if (nums[i] + nums[nums.length - 1] + nums[nums.length - 2] + nums[nums.length - 3] < target) { + continue; + } + if (i > 0 && nums[i] == nums[i - 1]) { + continue; + } + + for (int j = i + 1; j < nums.length - 2; j++) { + if (nums[i] + nums[j] + nums[j + 1] + nums[j + 2] > target) { + break; + } + if (nums[i] + nums[j] + nums[nums.length - 1] + nums[nums.length - 2] < target) { + continue; + } + if (j > i + 1 && nums[j] == nums[j - 1]) { + continue; + } + + int low = j + 1, high = nums.length - 1; + while (low < high) { + int sum = nums[i] + nums[j] + nums[low] + nums[high]; + if (sum == target) { + result.add(Arrays.asList(nums[i], nums[j], nums[low], nums[high])); + while (low < high && nums[low] == nums[low + 1]) { + low++; + } + while (low < high && nums[high] == nums[high - 1]) { + high--; + } + low++; + high--; + } else if (sum < target) { + low++; + } else { + high--; + } + } + } + } + return result; + } +} From 825d17a89095571b1624ea4f9021ef79f8f629f6 Mon Sep 17 00:00:00 2001 From: Shen Jie Date: Sun, 25 Jun 2017 22:15:20 +0800 Subject: [PATCH 46/53] Java solution 7 && 9 --- java/_007ReverseInteger.java | 42 ++++++++++++++++++++++++++++++++++ java/_009PalindromeNumber.java | 35 ++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 java/_007ReverseInteger.java create mode 100644 java/_009PalindromeNumber.java diff --git a/java/_007ReverseInteger.java b/java/_007ReverseInteger.java new file mode 100644 index 0000000..0eff619 --- /dev/null +++ b/java/_007ReverseInteger.java @@ -0,0 +1,42 @@ +/** + * Reverse digits of an integer. + *

+ * Example1: x = 123, return 321 + * Example2: x = -123, return -321 + *

+ * Have you thought about this? + * Here are some good questions to ask before coding. Bonus points for you if you have already thought through this! + *

+ * If the integer's last digit is 0, what should the output be? ie, cases such as 10, 100. + * Did you notice that the reversed integer might overflow? Assume the input is a 32-bit integer, then the reverse of + * 1000000003 overflows. How should you handle such cases? + * For the purpose of this problem, assume that your function returns 0 when the reversed integer overflows. + *

+ * Note: + * The input is assumed to be a 32-bit signed integer. Your function should return 0 when the reversed integer + * overflows. + *

+ * Created by drfish on 25/06/2017. + */ +public class _007ReverseInteger { + public int reverse(int x) { + int result = 0; + while (x != 0) { + int tail = x % 10; + int temp = result * 10 + tail; + if ((temp - tail) / 10 != result) { + return 0; + } + result = temp; + x /= 10; + } + return result; + } + + public static void main(String[] args) { + _007ReverseInteger solution = new _007ReverseInteger(); + assert 321 == solution.reverse(123); + assert -321 == solution.reverse(-123); + assert 0 == solution.reverse(2147483647); + } +} diff --git a/java/_009PalindromeNumber.java b/java/_009PalindromeNumber.java new file mode 100644 index 0000000..602e848 --- /dev/null +++ b/java/_009PalindromeNumber.java @@ -0,0 +1,35 @@ +/** + * Determine whether an integer is a palindrome. Do this without extra space. + *

+ * Some hints: + * Could negative integers be palindromes? (ie, -1) + *

+ * If you are thinking of converting the integer to string, note the restriction of using extra space. + *

+ * You could also try reversing an integer. However, if you have solved the problem "Reverse Integer", you know that + * the reversed integer might overflow. How would you handle such case? + *

+ * There is a more generic way of solving this problem. + *

+ * Created by drfish on 25/06/2017. + */ +public class _009PalindromeNumber { + public boolean isPalindrome(int x) { + if (x < 0 || (x != 0 && x % 10 == 0)) { + return false; + } + int reverse = 0; + while (x > reverse) { + reverse = reverse * 10 + x % 10; + x /= 10; + } + return (x == reverse || x == reverse / 10); + } + + public static void main(String[] args) { + _009PalindromeNumber solution = new _009PalindromeNumber(); + assert solution.isPalindrome(12321); + assert solution.isPalindrome(123321); + assert !solution.isPalindrome(-121); + } +} From 8bd9987b648aaf80b789480afce7c03a32ebb898 Mon Sep 17 00:00:00 2001 From: Shen Jie Date: Sun, 19 Nov 2017 15:30:44 +0800 Subject: [PATCH 47/53] Add java solution for 13 --- java/_013RomanToInteger.java | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 java/_013RomanToInteger.java diff --git a/java/_013RomanToInteger.java b/java/_013RomanToInteger.java new file mode 100644 index 0000000..40fe606 --- /dev/null +++ b/java/_013RomanToInteger.java @@ -0,0 +1,36 @@ +import java.util.HashMap; +import java.util.Map; + +/** + * Created by drfish on 25/06/2017. + */ +public class _013RomanToInteger { + public int romanToInt(String s) { + Map map = new HashMap() {{ + put('M', 1000); + put('D', 500); + put('C', 100); + put('L', 50); + put('X', 10); + put('V', 5); + put('I', 1); + }}; + int result = 0; + for (int i = 0; i < s.length(); i++) { + if (i > 0 && map.get(s.charAt(i)) > map.get(s.charAt(i - 1))) { + result -= map.get(s.charAt(i - 1)); + result += map.get(s.charAt(i)) - map.get(s.charAt(i - 1)); + } else { + result += map.get(s.charAt(i)); + } + } + return result; + } + + public static void main(String[] args) { + _013RomanToInteger solution = new _013RomanToInteger(); + assert 12 == solution.romanToInt("XII"); + assert 21 == solution.romanToInt("XXI"); + assert 99 == solution.romanToInt("XCIX"); + } +} From aef77bcb103461680786e0634dc15ffb25d0db0d Mon Sep 17 00:00:00 2001 From: "lihen.sj" Date: Wed, 29 Nov 2017 13:34:35 +0800 Subject: [PATCH 48/53] Java solution 283 & 292 --- java/_283MoveZeroes.java | 26 ++++++++++++++++++++++++++ java/_292NimGame.java | 12 ++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 java/_283MoveZeroes.java create mode 100644 java/_292NimGame.java diff --git a/java/_283MoveZeroes.java b/java/_283MoveZeroes.java new file mode 100644 index 0000000..0c93be9 --- /dev/null +++ b/java/_283MoveZeroes.java @@ -0,0 +1,26 @@ +/** + * Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements. + * + * For example, given nums = [0, 1, 0, 3, 12], after calling your function, nums should be [1, 3, 12, 0, 0]. + * + * Note: + * You must do this in-place without making a copy of the array. + * Minimize the total number of operations. + */ + +public class _283MoveZeroes { + public void moveZeroes(int[] nums) { + if (nums == null || nums.length == 0) { + return; + } + int index = 0; + for (int i = 0; i < nums.length; i++) { + if (nums[i] != 0) { + nums[index++] = nums[i]; + } + } + for (int i = index; i < nums.length; i++) { + nums[i] = 0; + } + } +} \ No newline at end of file diff --git a/java/_292NimGame.java b/java/_292NimGame.java new file mode 100644 index 0000000..b1727fb --- /dev/null +++ b/java/_292NimGame.java @@ -0,0 +1,12 @@ +/** + * You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone will be the winner. You will take the first turn to remove the stones. + * + * Both of you are very clever and have optimal strategies for the game. Write a function to determine whether you can win the game given the number of stones in the heap. + * + * For example, if there are 4 stones in the heap, then you will never win the game: no matter 1, 2, or 3 stones you remove, the last stone will always be removed by your friend. + */ +public class _292NimGame { + public boolean canWinNim(int n) { + return n % 4 != 0; + } +} \ No newline at end of file From 817ea162a34efb5c0a18249836a4f34534475e58 Mon Sep 17 00:00:00 2001 From: drfish <1993sj1993@gmail.com> Date: Wed, 29 Nov 2017 20:07:48 +0800 Subject: [PATCH 49/53] Java solution 257 & 258 --- java/_257BinaryTreePaths.java | 41 +++++++++++++++++++++++++++++++++++ java/_258AddDigits.java | 16 ++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 java/_257BinaryTreePaths.java create mode 100644 java/_258AddDigits.java diff --git a/java/_257BinaryTreePaths.java b/java/_257BinaryTreePaths.java new file mode 100644 index 0000000..2d93aa3 --- /dev/null +++ b/java/_257BinaryTreePaths.java @@ -0,0 +1,41 @@ +import java.util.List; + +import javax.management.relation.RelationTypeSupport; +import javax.swing.tree.TreeNode; + +/** + * Given a binary tree, return all root-to-leaf paths. + * + * For example, given the following binary tree: + * + * 1 + * / \ + * 2 3 + * \ + * 5 + * All root-to-leaf paths are: + * + * ["1->2->5", "1->3"] + */ + +public class _257BinaryTreePaths { + public List binaryTreePaths(TreeNode root) { + List result = new ArrayList<>(); + if (root != null) { + search(root, "", result); + } + return result; + } + + public void search(TreeNode node, String path, List result) { + if (node.left == null && node.right == null) { + result.add(path + node.val); + } + if (node.left != null) { + search(node.left, path + node.val + "->", result); + } + if (node.right != null) { + search(node.right, path + node.val + "->", result); + } + } +} \ No newline at end of file diff --git a/java/_258AddDigits.java b/java/_258AddDigits.java new file mode 100644 index 0000000..b458fca --- /dev/null +++ b/java/_258AddDigits.java @@ -0,0 +1,16 @@ +/** + * Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. + * + * For example: + * + * Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has only one digit, return it. + * + * Follow up: + * Could you do it without any loop/recursion in O(1) runtime? + */ +public class _258AddDigits { + public int addDigits(int num) { + int result = num % 9; + return (result != 0 || num == 0) ? result : 9; + } +} \ No newline at end of file From 2a71961be8f2cc3aec0365d1fc6c4a152a99d46c Mon Sep 17 00:00:00 2001 From: drfish Date: Thu, 30 Nov 2017 20:01:00 +0800 Subject: [PATCH 50/53] Java solution 387 --- java/_387FirstUniqueCharacterinaString.java | 27 +++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 java/_387FirstUniqueCharacterinaString.java diff --git a/java/_387FirstUniqueCharacterinaString.java b/java/_387FirstUniqueCharacterinaString.java new file mode 100644 index 0000000..33581af --- /dev/null +++ b/java/_387FirstUniqueCharacterinaString.java @@ -0,0 +1,27 @@ +/** + * + * Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1. + * + * Examples: + * + * s = "leetcode" + * return 0. + * + * s = "loveleetcode", + * return 2. + * Note: You may assume the string contain only lowercase letters. + */ +public class _387FirstUniqueCharacterinaString { + public int firstUniqChar(String s) { + int[] frequency = new int[26]; + for (int i = 0; i < s.length(); i++) { + frequency[s.charAt(i) - 'a']++; + } + for (int i = 0; i < s.length(); i++) { + if (frequency[s.charAt(i) - 'a'] == 1) { + return i; + } + } + return -1; + } +} \ No newline at end of file From 4b4088dcaf92687f9f2cb73c7f6da2ab1209000d Mon Sep 17 00:00:00 2001 From: drfish <1993sj1993@gmail.com> Date: Thu, 7 Dec 2017 18:43:24 +0800 Subject: [PATCH 51/53] Java solution 274 & 299 --- java/_274H_Index.java | 33 +++++++++++++++++++++++++++++++++ java/_299BullsandCows.java | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 java/_274H_Index.java create mode 100644 java/_299BullsandCows.java diff --git a/java/_274H_Index.java b/java/_274H_Index.java new file mode 100644 index 0000000..1295324 --- /dev/null +++ b/java/_274H_Index.java @@ -0,0 +1,33 @@ +/** + * Given an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher's h-index. + * + * According to the definition of h-index on Wikipedia: "A scientist has index h if h of his/her N papers have at least h citations each, and the other N − h papers have no more than h citations each." + * + * For example, given citations = [3, 0, 6, 1, 5], which means the researcher has 5 papers in total and each of them had received 3, 0, 6, 1, 5 citations respectively. Since the researcher has 3 papers with at least 3 citations each and the remaining two with no more than 3 citations each, his h-index is 3. + * + * Note: If there are several possible values for h, the maximum one is taken as the h-index. + */ +public class _274H_Index { + public int hIndex(int[] citations) { + if (citations == null || citations.length == 0) { + return 0; + } + int n = citations.length; + int[] cnts = new int[n + 1]; + for (int citation : citations) { + if (citation >= n) { + cnts[n]++; + } else { + cnts[citation]++; + } + } + int count = 0; + for (int i = n; i >= 0; i--) { + count += cnts[i]; + if (count >= i) { + return i; + } + } + return 0; + } +} \ No newline at end of file diff --git a/java/_299BullsandCows.java b/java/_299BullsandCows.java new file mode 100644 index 0000000..425d3e6 --- /dev/null +++ b/java/_299BullsandCows.java @@ -0,0 +1,38 @@ +/** + * You are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to guess what the number is. Each time your friend makes a guess, you provide a hint that indicates how many digits in said guess match your secret number exactly in both digit and position (called "bulls") and how many digits match the secret number but locate in the wrong position (called "cows"). Your friend will use successive guesses and hints to eventually derive the secret number. + * + * For example: + * + * Secret number: "1807" + * Friend's guess: "7810" + * Hint: 1 bull and 3 cows. (The bull is 8, the cows are 0, 1 and 7.) + * Write a function to return a hint according to the secret number and friend's guess, use A to indicate the bulls and B to indicate the cows. In the above example, your function should return "1A3B". + * + * Please note that both secret number and friend's guess may contain duplicate digits, for example: + * + * Secret number: "1123" + * Friend's guess: "0111" + * In this case, the 1st 1 in friend's guess is a bull, the 2nd or 3rd 1 is a cow, and your function should return "1A1B". + * You may assume that the secret number and your friend's guess only contain digits, and their lengths are always equal. + */ +public class _299BullsandCows { + public String getHint(String secret, String guess) { + int a = 0; + int b = 0; + int[] array1 = new int[10]; + int[] array2 = new int[10]; + for (int i = 0; i < secret.length(); i++) { + if (secret.charAt(i) == guess.charAt(i)) { + a++; + } else { + array1[secret.charAt(i) - '0']++; + array2[guess.charAt(i) - '0']++; + } + } + for (int i = 0; i < 10; i++) { + b += Math.min(array1[i], array2[i]); + } + String result = a + "A" + b + "B"; + return result; + } +} \ No newline at end of file From f82d816012298b3c59bfabfa0789da5f26d46fc5 Mon Sep 17 00:00:00 2001 From: drfish <1993sj1993@gmail.com> Date: Fri, 8 Dec 2017 09:59:45 +0800 Subject: [PATCH 52/53] Java solution 273 & 260 --- java/_260SingleNumberIII.java | 29 ++++++++++++++++++ java/_273IntegertoEnglishWords.java | 46 +++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 java/_260SingleNumberIII.java create mode 100644 java/_273IntegertoEnglishWords.java diff --git a/java/_260SingleNumberIII.java b/java/_260SingleNumberIII.java new file mode 100644 index 0000000..6e6b8b0 --- /dev/null +++ b/java/_260SingleNumberIII.java @@ -0,0 +1,29 @@ +/** + * Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once. + * + * For example: + * + * Given nums = [1, 2, 1, 3, 2, 5], return [3, 5]. + * + * Note: + * The order of the result is not important. So in the above example, [5, 3] is also correct. + * Your algorithm should run in linear runtime complexity. Could you implement it using only constant space complexity? + */ +public class _260SingleNumberIII { + public int[] singleNumber(int[] nums) { + int diff = 0; + for (int num : nums) { + diff ^= num; + } + diff &= -diff; + int[] result = { 0, 0 }; + for (int num : nums) { + if ((num & diff) == 0) { + result[0] ^= num; + } else { + result[1] ^= num; + } + } + return result; + } +} \ No newline at end of file diff --git a/java/_273IntegertoEnglishWords.java b/java/_273IntegertoEnglishWords.java new file mode 100644 index 0000000..5579c4c --- /dev/null +++ b/java/_273IntegertoEnglishWords.java @@ -0,0 +1,46 @@ +import javax.swing.text.AbstractDocument.LeafElement; + +/** + * Convert a non-negative integer to its english words representation. Given input is guaranteed to be less than 231 - 1. + * + * For example, + * 123 -> "One Hundred Twenty Three" + * 12345 -> "Twelve Thousand Three Hundred Forty Five" + * 1234567 -> "One Million Two Hundred Thirty Four Thousand Five Hundred Sixty Seven" + */ +public class _273IntegertoEnglishWords { + private static final String[] LESS_THAN_20 = { "", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", + "Nine", "Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", + "Nineteen" }; + private static final String[] TENS = { "", "", "Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", + "Eighty", "Ninety" }; + private static final String[] THOUSANDS = { "", "Thousand", "Million", "Billion" }; + + public String numberToWords(int num) { + if (num == 0) { + return "Zero"; + } + int i = 0; + String result = ""; + while (num > 0) { + if (num % 1000 != 0) { + result = helper(num % 1000) + THOUSANDS[i] + " " + result; + } + num /= 1000; + i++; + } + return result.trim(); + } + + private String helper(int num) { + if (num == 0) { + return ""; + } else if (num < 20) { + return LESS_THAN_20[num] + " "; + } else if (num < 100) { + return TENS[num / 10] + " " + helper(num % 10); + } else { + return LESS_THAN_20[num / 100] + " Hundred " + helper(num % 100); + } + } +} \ No newline at end of file From 92bf28abf81a4cbf988d6595b9e42a6ee1b9071d Mon Sep 17 00:00:00 2001 From: Shen Jie Date: Tue, 19 Mar 2019 22:52:42 +0800 Subject: [PATCH 53/53] Python solution for 207 --- python/207 Course Schedule.py | 50 +++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 python/207 Course Schedule.py diff --git a/python/207 Course Schedule.py b/python/207 Course Schedule.py new file mode 100644 index 0000000..86cf7b0 --- /dev/null +++ b/python/207 Course Schedule.py @@ -0,0 +1,50 @@ +''' +There are a total of n courses you have to take, labeled from 0 to n-1. + +Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a pair: [0,1] + +Given the total number of courses and a list of prerequisite pairs, is it possible for you to finish all courses? + +Example 1: + +Input: 2, [[1,0]] +Output: true +Explanation: There are a total of 2 courses to take. + To take course 1 you should have finished course 0. So it is possible. +Example 2: + +Input: 2, [[1,0],[0,1]] +Output: false +Explanation: There are a total of 2 courses to take. + To take course 1 you should have finished course 0, and to take course 0 you should + also have finished course 1. So it is impossible. +Note: + + 1. The input prerequisites is a graph represented by a list of edges, not adjacency matrices. Read more about how a graph is represented. + 2. You may assume that there are no duplicate edges in the input prerequisites. +''' + + +class Solution: + def canFinish(self, numCourses: int, prerequisites: [[]]) -> bool: + graph = {n: [] for n in range(numCourses)} + for x, y in prerequisites: + graph[x].append(y) + + for target in range(numCourses): + stack = graph[target] + visited = set() + while stack: + course = stack.pop() + visited.add(course) + if course == target: + return False + for i in graph[course]: + if i not in visited: + stack.append(i) + return True + + +if __name__ == "__main__": + assert True == Solution().canFinish(2, [[1, 0]]) + assert False == Solution().canFinish(2, [[1, 0], [0, 1]])