/Exercises

Java and C++ Solutions for Leetcode.

Primary LanguageJava

Playground for Leetcode Questions.

Trying to solve every question with as many solutions as I can.

Now in Phase II!

  • Phase II Review all the questions completed so far, add "code tags" to each of them, try to cover similar questions if necessary.

  • Phase I Complete 150 questions.

Question Table

Updating ~~~

1. array

# *** Name Code Tags Groups
1 E Two Sum Sort + Two Pointers, Hashtable K-Sum
15 M Three Sum Sort + Two Pointers K-Sum
18 M Four Sum Sort + Two Pointers, Backtracking K-Sum
167 M Two Sum Sorted Sort + Two Pointers, Hashtable, Binary Search K-Sum
170 E Two Sum Data Structure Hashtable K-Sum
16 M Three Sum Closest Sort + Two Pointers K-Sum
259 M Three Sum Smaller Sort + Two Pointers K-Sum
26 E Remove Duplicates From Sorted Array Two Pointers -
27 E Remove Element Two Pointers -
66 E Plus One Math: Carry -
88 E Merge Sorted Array Two Pointers, Reverse Scan, Sentinel -
118 E Pascal Triangle Reverse Scan, Sentinel Pascal Triangle
119 E Pascal Triangle 2 Reverse Scan, DP Pascal Triangle
136 E Single Number XOR Single Number
137 M Single Number 2 XOR Single Number
260 M Single Number 3 XOR Single Number
169 E Majority Element Moore Voting, Hashtable, Sort Majority Element
229 M Majority Element 2 Moore Voting, Hashtable Majority Element
189 E Rotate Array Divide & Conquer, Two Pointers -
191 E Hamming Weight Bit Manipulation Hamming
461 E Hamming Distance Bit Manipulation Hamming
217 E Contains Duplicate Hashtable, Sort Contains Duplicate
219 E Contains Duplicate 2 Hashtable, Sliding Window Contains Duplicate
220 M Contains Duplicate 3 Bucket Sort, TreeSet, Sliding Window Contains Duplicate
243 E Shortest Word Distance Two Pointers, Sentinel Word Distance
244 M Shortest Word Distance 2 Two Pointers, Hashtable, String Word Distance
245 M Shortest Word Distance 3 Two Pointers Word Distance
283 E Move Zeroes Two Pointers -
4 H Median of Two Sorted Arrays Binary Search, Two Pointers -
33 H Search Rotated Array Binary Search, Two Pointers, Rotation Rotated Sorted Array
81 M Search Rotated Array 2 Binary Search, Two Pointers, Rotation Rotated Sorted Array
153 M Find Min in Rotated Sorted Array Binary Search, Two Pointers, Rotation Rotated Sorted Array
154 H Find Min in Rotated Sorted Array 2 Binary Search, Two Pointers, Rotation Rotated Sorted Array
11 M Container With Most Water Two Pointers, Early Exit -
34 M Search For Range Binary Search, Two Pointers, Sort Search Range
35 M Search Insert Position Binary Search, Two Pointers Search Range
278 E First Bad Version Binary Search Search Range
374 E Guess Number Binary Search, Ternary Search Search Range
228 M Summary Range Two Pointers, Int2Str -
268 M Missing Number Bit Manipulation, Binary Search -
287 M Find Duplicate Number Binary Search, Two Pointers, Hashtable, Value-as-Index, Sort Cycle Detection

2. hashtable

# *** Name Code Tags Groups
36 E Valid Sudoku HashSet, Matrix Manipulation -
202 E Happy Number HashSet, Two Pointers -
204 E Counting Prime HashSet, Boolean Array, Math -
205 E Isomorphic String HashMap, Value-As-Index Mapping
290 E Word Pattern HashMap, String.split Mapping
242 E Valid Anagram HashMap, Value-As-Index, Sort/Scan Anagram
49 M Group Anagrams HashMap, String Sort Anagram
438 E Find Anagram In String Slide Window, Two Pointers, Value-As-Index Anagram
246 E Strobogrammatic Number HashMap, Two Pointers -
249 E Group Shifted String HashMap, Math -
266 E Palindrome Permutation HashSet, Coin-Flipping, Value-As-Index Palindrome
267 M Palindrome Permutation 2 HashMap, Value-As-Index, Backtracking Palindrome
409 E Longest Palindrome HashMap, Coin-Flipping, Value-As-Index Palindrome
288 E Unique Abbreviation HashSet, HashMap -
299 E Bulls And Cows Value-As-Index, Coin-Flipping -
349 E Intersection of Arrays Sort, Two Pointers, Binary Search, HashSet -
350 E Intersection of Arrays 2 Sort, HashMap -
359 E Logger Rate Limiter HashMap -
389 E Find String Difference HashMap, Bit Manipulation, Coin-Flipping -
3 M Longest Substring Without Repeating Characters HashMap, Two Pointers, String Scan -
187 M Repeated DNA Sequences HashMap, HashSet, Substring -
347 M Top K Frequent Element Bucket, HashMap, Generic Frequency
451 M Sort Characters By Frequency Bucket, HashMap, Value-As-Index Frequency

3. linkedlist

# *** Name Code Tags Groups
2 E Add Two Numbers Dummy Node, Two Pointers, Sentinel, Math Add Two Num
445 M Add Two Numbers 2 Tail Align, Dummy Node, Two Pointers, Sentinel Add Two Num
369 M Plus One (Linked List) Recursion, Reverse, Two Pointers Add Two Num
19 E Remove Nth From End Dummy Node, Recursion, Two Pointers -
21 E Merge Sorted Linked List Dummy Node, Recursion, Sentinel -
24 E Swap Nodes in Pairs Dummy Node, Tri-Pointers, Recursion -
83 E Remove Duplicate Nodes Two Pointers, Recursion Remove Nodes
82 M Remove Duplicate Nodes 2 Dummy Node, Two Pointers, Recursion Remove Nodes
203 E Remove Element Node Delete, Dummy Node, Two Pointers Remove Nodes
237 E Delete Node Node Delete Remove Nodes
141 E Linked List Cycle Two Pointers, Floyd Loop Detection, HashSet Cycle Detection
142 E Linked List Cycle 2 Two Pointers, Floyd Loop Detection, HashSet Cycle Detection
160 E Intersection of Linked List Two Pointers, Loop Detection, Tail Align, HashSet -
206 E Reverse Linked List Two Pointers, Dummy Node, Recursion Linkedlist Reverse
92 M Reverse Linked List 2 Two Pointers, Dummy Node Linkedlist Reverse
234 E Palindrome Linked List Two Pointers, Dummy Node, Recursion Linkedlist Reverse
143 M Reorder Linked List Two Pointers, Reverse Linkedlist Reverse
61 M Rotate Linked List Two Pointers, Loop -
147 M Implement Insertion Sort (Linked List) Two Pointers, Dummy Node, Recursion Sort
148 M Implement Merge Sort (Linked List) Two Pointers, Dummy Node Shift, Cut Sort
328 M Odd Even Linked List Two Pointers, Dummy Node Shift -