My leetcode solutions
Profile: https://leetcode.com/piash001
Problem No. | Problem and Solution link | Algorithm type |
---|---|---|
1 | Problem: Two Sum Solution: Solution Link |
Array, Hashmap |
2 | Problem: Add two numbers Solution: Solution Link |
Linked list |
3 | Problem: Longest Substring Without Repeating Characters Solution: Solution Link |
String, Sliding window, HashMap |
11 | Problem: Container With Most Water Solution: [Solution Link](11-Container With Most Water.js) |
Two Pointer, Greedy, Array |
12 | Problem: Integer to Roman Solution: [Solution Link](12-Integer to Roman.js) |
Hash |
17 | Problem: Letter Combinations of a Phone Number Solution: [Solution Link](17-Letter Combinations of a Phone Number.js) |
Hash, DFS, Backtrack |
21 | Problem: Merge Two Sorted Lists Solution: Solution Link |
Linked list |
34 | Problem: Find First and Last Position of Element in Sorted Array Solution Link |
Binary search |
57 | Problem: Insert Interval [Solution Link](57-Insert Interval.js) |
Array |
69 | Problem: Sqrt(x) Solution Link |
Binary search |
74 | Problem: Search a 2D Matrix Solution Link |
Binary search, Divide and Conquer, Matrix |
83 | Problem: Remove Duplicates from Sorted List [Solution Link](83-Remove Duplicates from Sorted List.js) |
Linked list |
88 | Problem: Merge Sorted Array [Solution Link](88-Merge Sorted Array.js) |
Two pointer / One pointer |
94 | Problem: Binary Tree Inorder Traversal [Solution Link](94-Binary Tree Inorder Traversal.js) |
Binary Tree, DFS, Tree, Inorder traversal |
100 | Problem: Same Tree [Solution Link](100-Same Tree.txt) |
Binary tree |
101 | Problem: Symmetric Tree [Solution Link](101: Symmetric Tree.js) |
Binary tree, Recursion |
104 | Problem: Maximum Depth of Binary Tree [Solution Link](114-Maximum Depth of Binary Tree.js) |
Binary tree, DFS, BFS |
108 | Problem: Convert Sorted Array to Binary Search Tree [Solution Link](108-Convert Sorted Array to Binary Search Tree.js) |
Tree, Binary Search tree, Array |
110 | Problem: Balanced Binary Tree [Solution Link](110-Balanced Binary Tree.js) |
Tree, Binary tree, DFS |
111 | Problem: Minimum Depth of Binary Tree [Solution Link](111-Minimum Depth of Binary Tree.js) |
Tree, Binary tree, BFS |
112 | Problem: Path Sum [Solution Link](112-Path Sum.js) |
Tree, Binary tree, DFS |
114 | Problem: Flatten Binary Tree to Linked List [Solution Link](114-Flatten Binary Tree to Linked List.js) |
Binary tree, Morris traversal(need study), Linked List, |
118 | Problem: Pascal's Triangle [Solution Link](118-Pascals Triangle.js) |
Adhoc |
119 | Problem: Pascal's Triangle-II [Solution Link](119-Pascals Triangle-II.js) |
Adhoc |
121 | Problem: Best Time to Buy and Sell Stock [Solution Link](121-Best Time to Buy and Sell Stock.js) |
Array, Max. Sub array, Kadane's Algo |
125 | Problem: Valid Palindrome [Solution Link](125-Valid Palindrome.js) |
Adhoc, Two Pointers |
134 | Problem: Single Number [Solution Link](134-Single Number.js) |
Array, Greedy, Max num of point visit in a circular manner |
136 | Problem: Single Number [Solution Link](136-Single Number.js) |
Bitwise manipulation, hash (worse) |
141 | Problem: Linked List Cycle [Solution Link](141-Linked List Cycle.js) |
Linked List, Hashing, Floyd’s Cycle Detection Algorithm |
149 | Problem: Max Points on a Line [Solution Link](149-Max Points on a Line.js) |
Array, Math, Geometry |
160 | Problem: Intersection of Two Linked Lists [Solution Link](160-Intersection of Two Linked Lists.js) |
Linked List, Two Pointer |
167 | Problem: Two Sum II - Input Array Is Sorted Solution Link JS Solution Link php |
Array, hashmap, two pointer, binary search |
169 | Problem: Majority Element [Solution Link](169-Majority Element.js) |
Hashing, Sorting, Boyer-Moore Voting Algorithm |
171 | Problem: Excel Sheet Column Number [Solution Link](171-Excel Sheet Column Number.js) |
String, Math, |
190 | Problem: Reverse Bits [Solution Link](190-Reverse Bits.js) |
Bit manipulation |
191 | Problem: Number of 1 Bits [Solution Link](191-Number of 1 Bits.js) |
Bit manipulation |
200 | Problem: Number of Islands [Solution Link](200-Number of Islands.js) |
DFS, BFS |
202 | Problem: Happy Number [Solution Link](202-Happy Number.js) |
Math |
203 | Problem: Remove Linked List Elements [Solution Link](203-Remove Linked List Elements.js) |
Linked List |
206 | Problem: Reverse Linked List Solution: [Solution Link](206-Reverse Linked List.js) |
Linked List |
207 | Problem: Course Schedule Solution: Solution Link |
Topological sort |
210 | Problem: Course Schedule II Solution: Solution Link |
Topological sort |
217 | Problem: Contains Duplicate Solution: [Solution Link](217-Contains Duplicate.js) |
Set, Hash |
235 | Problem: Lowest Common Ancestor of a Binary Search Tree Solution: Solution Link |
DFS, Binary Tree |
236 | Problem: Lowest Common Ancestor of a Binary Tree Solution: Solution Link |
DFS, Binary Tree |
240 | Problem: Search A 2d Matrix II Solution Link |
Binary search, Divide and Conquer, Matrix |
242 | Problem: Valid Anagram [Solution Link](242-Valid Anagram.js) |
Binary search, Divide and Conquer, Matrix |
263 | Problem: Ugly Number [Solution Link](263-Ugly Number.php) |
Math |
283 | Problem: Move Zeroes [Solution Link](283-Move Zeroes.js) |
Array, pointer |
290 | Problem: Word Pattern [Solution Link](290-Word Pattern.js) |
Hash, string |
300 |
Problem: Longest Increasing Subsequence [Solution Link](300-Longest Increasing Subsequence.cs) |
DP, Binary search |
322 | Problem: Coin Change [Solution Link](141-Coin Change.js) |
DP, top-down approach, can pick infinite no. of items |
326 | Problem: Power of Three [Solution Link](326-Power of Three.js) |
Math |
345 | Problem: Reverse Vowels of a String [Solution Link](345-Reverse Vowels of a String.js) |
String, Two pointers |
350 | Problem: Intersection of Two Arrays II [Solution Link](350-Intersection of Two Arrays II.js) |
Array, Hashmap, Count |
384 | Problem: Shuffle an Array [Solution Link](384-Shuffle an Array.js) |
Array, Math, Random Number |
387 | Problem: First Unique Character in a String [Solution Link](387-First Unique Character in a String.cs) |
Hash |
412 | Problem: Fizz Buzz [Solution Link](412-Fizz Buzz.cs) |
Math |
443 | Problem: String Compression [Solution Link](412-443-String Compression.js) |
String, Array, Two Pointers |
452 | Problem: Minimum Number of Arrows to Burst Balloons [Solution Link](452-Minimum Number of Arrows to Burst Balloons.js) |
Array, Greedy, Minimum number of segment |
509 | Problem: Fibonacci Number [Solution Link](509-Fibonacci Number.js) |
DP, top-down approach, Fibonacci |
520 | Problem: Detect Capital [Solution Link](520-Detect Capital.js) |
String |
804 | Problem: Unique Morse Code Words [Solution Link](804-Unique Morse Code Words.js) |
Hashmap, Set |
890 | Problem: Find and Replace Pattern [Solution Link](890-Find and Replace Pattern.js) |
Hashmap (Two or one mapping), Array,String match |
918 | Problem: Maximum Sum Circular Subarray [Solution Link](918-Maximum Sum Circular Subarray.js) |
Array, Max Min, Circular Sub-array |
944 | Problem: Delete Columns to Make Sorted [Solution Link](944-Delete Columns to Make Sorted.js) |
Array, String, Adhoc |
974 | Problem: Subarray Sums Divisible by K [Solution Link](974-Subarray Sums Divisible by K.js) |
Array, Prefix Sum, Hashmap |
974 | Problem: Subarray Sums Divisible by K [Solution Link](974-Subarray Sums Divisible by K.js) |
Array, Prefix Sum, Hashmap |
989 | Problem: Add to Array-Form of Integer [Solution Link](989-Add to Array-Form of Integer.js) |
Array, digit sum |
1071 | Problem: Greatest Common Divisor of Strings](https://leetcode.com/problems/greatest-common-divisor-of-strings) [Solution Link](1071-Greatest Common Divisor of Strings.js) |
String, GCD |
1137 | Problem: N-th Tribonacci Number [Solution Link](1137-N-th Tribonacci Number.php) |
Array, Math |
1338 | Problem: Reduce Array Size to The Half [Solution Link](1338-Reduce Array Size to The Half.js) |
Hash, Sort, Greedy |
1833 | Problem: Maximum Ice Cream Bars [Solution Link](1833-Maximum Ice Cream Bars.js) |
Sort, Array, Greedy, Max number of item can be obtained |
1462 | Problem: Course Schedule IV Solution Link |
BFS |
2007 | Problem: Find Original Array From Doubled Array [Solution Link](2007-Find Original Array From Doubled Array.js) |
Array, Hash |
2244 | Problem: Minimum Rounds to Complete All Tasks [Solution Link](2244. Minimum Rounds to Complete All Tasks.js) |
Array, Hashmap |
2274 | Problem: Maximum Consecutive Floors Without Special Floors [Solution Link](2274-Maximum Consecutive Floors Without Special Floors.js) |
Array, Sentinel, Maximum consecutive |
2389 | Problem: Longest Subsequence With Limited Sum [Solution Link](2389-Longest Subsequence With Limited Sum.js) |
Prefix sum, Greedy, Binary Search |