ArcturusZhang / PlayedByLeetCode

My leetcode solution repo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

My solutions for LeetCode

I will put my solutions (of course, the accepted ones) of Leetcode Problems in this repo. Every problem will be done in Java.

Problems

ID Problem Relative Topic
001 Two Sum Brutal Force, Hash Table
002 Add Two Numbers Integer Addition
003 Longest Substring Without Repeating Characters Double Pointers
004 Median of Two Sorted Arrays Merge Sort
005 Longest Palindromic Substring Dynamic Programming
006 ZigZag Conversion Brutal Force
007 Reverse Integer Brutal Force
008 String to Integer (atoi) Brutal Force
009 Palindrome Number Brutal Force (Reverse Half)
010 Regular Expression Matching Brutal Force
011 Container With Most Water Greedy
012 Integer to Roman Brutal Force
013 Roman to Integer Brutal Force
014 Longest Common Prefix Brutal Force, Divide and Conquer (Not Implemented)
015 3Sum Binary Search
016 3Sum Closest Binary Search
017 Letter Combinations of a Phone Number Backtracking (DFS)
018 4Sum Binary Search
019 Remove Nth Node From End of List Double Pointers
020 Valid Parentheses Stack
021 Merge Two Sorted Lists Merge Sort
022 Generate Parentheses Dynamic Programming
023 Merge k Sorted Lists Merge Sort (Using Priority Queue)
024 Swap Nodes in Pairs Double Pointers, Stack
025 Reverse Nodes in k-Group Stack
026 Remove Duplicates from Sorted Array Brutal Force
027 Remove Element Brutal Force
028 Implement strStr() Brutal Force
029 Divide Two Integers Binary Long Division
030 Substring with Concatenation of All Words Hash Table
031 Next Permutation Single Pass Approach
032 Longest Valid Parentheses Stack, Dynamic Programming
033 Search in Rotated Sorted Array Binary Search
034 Search for a Range Binary Search
035 Search Insert Position Brutal Force, Binary Search
036 Valid Sudoku Brutal Force, Hash Table
037 Sudoku Solver Backtracking (DFS)
038 Count and Say Brutal Force
039 Combination Sum Backtracking (DFS)
040 Combination Sum II Backtracking (DFS)
041 First Missing Positive Bucket Sort
043 Multiply Strings Integer Long Multiplication
044 Wildcard Matching Brutal Force, Dynamic Programming
046 Permutations Backtracking (DFS)
047 Permutations II Backtracking (DFS)
048 Rotate Image Brutal Force
049 Group Anagrams Hash Table
050 Pow(x, n) Divide and Conquer
051 N-Queens Backtracking (DFS)
052 N-Queens-II Backtracking (DFS)
053 Maximum Subarray Dynamic Programming
056 Merge Intervals Brutal Force
057 Insert Interval Brutal Force
058 Length of Last Word Brutal Force
060 Permutation Sequence Brutal Force (Reuse 031)
061 Rotate List Linked List
062 Unique Paths Dynamic Programming
063 Unique Paths II Dynamic Programming
064 Minimum Path Sum Dynamic Programming
065 Valid Number Brutal Force
066 Plus One Integer Addition
067 Add Binary Binary Integer Addition
068 Text Justification Brutal Force
069 Sqrt(x) Brutal Force, Newton Method
070 Climbing Stairs Dynamic Programming (Fibonacci)
071 Simplify Path Stack
072 Edit Distance Dynamic Programming
073 Set Matrix Zeroes Hash Table
074 Search a 2D Matrix Binary Search
075 Sort Colors Hash Table
076 Minimum Window Substring Hash Table
077 Combinations Backtracking (DFS)
078 Subsets Backtracking (DFS)
079 Word Search Backtracking (DFS)
080 Remove Duplicates from Sorted Array II Brutal Force
082 Remove Duplicates from Sorted List II Linked List
083 Remove Duplicates from Sorted List Linked List
085 Maximal Rectangle Dynamic Programming
086 Partition List Linked List
087 Scramble String Dynamic Programming
089 Gray Code Bit Manipulation, Brutal Force
090 Subsets II Backtracking (DFS)
091 Decode Ways Backtracking, Dynamic Programming
092 Reverse Linked List II Stack
093 Restore IP Addresses Backtracking (DFS)
094 Binary Tree Inorder Traversal Binary Tree Traversal
095 Unique Binary Search Trees II
096 Unique Binary Search Trees Dynamic Programming
098 Validate Binary Search Tree Binary Tree Traversal
099 Recover Binary Search Tree Binary Tree Traversal
100 Same Tree Binary Tree
101 Symmetric Tree Binary Tree
102 Binary Tree Level Order Traversal Binary Tree Traversal
103 Binary Tree Zigzag Level Order Traversal Binary Tree Traversal
104 Maximum Depth of Binary Tree Binary Tree
105 Construct Binary Tree from Preorder and Inorder Traversal Binary Tree Traversal
106 Construct Binary Tree from Inorder and Postorder Traversal Binary Tree Traversal
107 Binary Tree Level Order Traversal II Binary Tree Traversal
108 Convert Sorted Array to Binary Search Tree Binary Tree
109 Convert Sorted List to Binary Search Tree Binary Tree & Linked List
110 Balanced Binary Tree Binary Tree Traversal
111 Minimum Depth of Binary Tree Binary Tree Traversal
112 Path Sum Binary Tree
113 Path Sum II Binary Tree & Backtracking (DFS)
114 Flatten Binary Tree to Linked List Binary Tree Traversal
115 Distinct Subsequences Dynamic Programming
116 Populating Next Right Pointers in Each Node Binary Tree & Linked List
117 Populating Next Right Pointers in Each Node II Binary Tree & Linked List
118 Pascal's Triangle Brutal Force
119 Pascal's Triangle II Brutal Force
120 Triangle Dynamic Programming
121 Best Time to Buy and Sell Stock Dynamic Programming
122 Best Time to Buy and Sell Stock II Greedy
123 Best Time to Buy and Sell Stock III Dynamic Programming
125 Valid Palindrome String (Palindrome)
126 Word Ladder II BFS & DFS, Graph (optimal path)
127 Word Ladder BFS
128 Longest Consecutive Sequence Sorting, Hash Table
129 Sum Root to Leaf Numbers Binary Tree Traversal (DFS)
130 Surrounded Regions DFS
133 Clone Graph DFS
136 Single Number Hash Table, Bit Manipulation
137 Single Number II Hash Table, Bit Manipulation
138 Copy List with Random Pointer Linked List
139 Word Break BFS, Dynamic Programming
140 Word Break II cached DFS
141 Linked List Cycle Double Pointers, Hash Table
142 Linked List Cycle II Double Pointers
143 Reorder List Linked List
144 Binary Tree Preorder Traversal Binary Tree Traversal
145 Binary Tree Postorder Traversal Binary Tree Traversal
148 Sort List Merge Sort
149 Max Points on a Line Hash table
160 Intersection of Two Linked Lists Hash Table, Linked List
167 Two Sum II - Input array is sorted Binary Search
168 Excel Sheet Column Title Math
169 Majority Element Hash Map
171 Excel Sheet Column Number Math
172 Factorial Trailing Zeroes Math
173 Binary Search Tree Iterator Binary Tree Inorder Traversal
174 Dungeon Game Dynamic Programming
179 Largest Number Sort
188 Best Time to Buy and Sell Stock IV Dynamic Programming
189 Rotate Array Arrays
190 Reverse Bits Bit Manipulation
191 Number of 1 Bits Bit Manipulation
198 House Robber Dynamic Programming
200 Number of Islands DFS, BFS
201 Bitwise AND of Numbers Range Bit Manipulation
202 Happy Number Hash Table
203 Remove Linked List Elements Linked List
204 Count Primes Sheive Method
205 Isomorphic Strings Hash Table
206 Reverse Linked List Linked List, Stack
207 Course Schedule Graph Topological Sort (DFS & BFS), Cyclic Path Detection
208 Implement Trie (Prefix Tree) Trie
212 Word Search II Backtracking (DFS), Trie
215 Kth Largest Element in an Array Heap Sort
237 Delete Node in a Linked List Linked List
221 Maximal Square Dynamic Programming
225 Implement Stack using Queues Stack, Queue
230 Kth Smallest Element in a BST Binary Search Tree
231 Power of Two Bit Manipulation
232 Implement Queue using Stacks Queue, Stack
233 Number of Digit One Math
234 Palindrome Linked List Linked List
235 Lowest Common Ancestor of a Binary Search Tree Binary Tree
236 Lowest Common Ancestor of a Binary Tree Binary Tree
297 Serialize and Deserialize Binary Tree BFS
230 Kth Smallest Element in a BST Binary Tree Traversal
231 Power of Two Bit Manipulation
232 Implement Queue using Stacks Stack, Queue
268 Missing Number Math, Bit Manipulation
287 Find the Duplicated Number Brutal Force, Two Pointers, Divide and Conquer
292 Nim Game Math
371 Sum of Two Integers Bit Manipulation
416 Partition Equal Subset Sum Dynamic Programming
437 Path Sum III Backtracking (DFS)
476 Number Complement Bit Manipulation
507 Perfect Number Math
516 Longest Palindromic Subsequence Dynamic Programming
695 Max Area of Island Backtracking (DFS)
725 Split Linked List in Parts Linked List

About

My leetcode solution repo


Languages

Language:Java 100.0%