If you find this repository helpful, please give me a star to inspire me to keep it updated and benefit more people. Thank you! 🌟
Grind 169 is a dynamic list of top LeetCode interview questions created in 2023. It's up-to-date and well-chosen. We can personalize it according to our schedule, time constraints, and preferences. For the completed Grind 75 solutions, please refer to this repository
Blind 75, on the other hand, is a curated list of LeetCode questions created in 2018. We can practice these questions to save time in the job-finding process. Many other LeetCode problems are technical mixes of these individual problems. I practice Blind 75 in parallel on this repository.
To achieve the review of the application of the following data structures and algorithms, except the theory of NP-Completeness.
- Data Structures: (1) Arrays; (2) Stacks and Queues; (3) Linked Lists; (4) Trees; (5) Graphs; (6) Sorting; (7) Hashing.
- Algorithms: (1) Greedy Method; (2) Divide and Conquer; (3) Tree Searching Strategies; (4) Prune and Search; (5) Dynamic Programming.
Recommended online textbook for quick review of concepts: Hello Algo
- Start Date: Apr 12, 2023
- Completion Date: Ongoing 🧙
In this repository, you'll find each question meticulously solved with a focus on clarity and efficiency. To ensure you can verify and understand the solutions:
- Organized Folders: Solutions are neatly organized into folders, labeled from Part 1 to Part 8, for easy navigation.
- Test Cases: Each solution is accompanied by test cases that validate the code and demonstrate its correctness.
- Complexity Analysis: Time and space complexities are provided for each solution, giving you insights into the efficiency of the algorithms used.
Feel free to delve into the solutions, run the test cases, and review the complexity analysis to deepen your understanding of each problem. This hands-on approach is designed to help you become proficient in coding interviews, where such analyses are crucial.
- Easy 1. Two Sum (picked in Blind 75)
- Easy 20. Valid Parentheses (picked in Blind 75)
- Easy 21. Merge Two Sorted Lists (picked in Blind 75)
- Easy 70. Climbing Stairs (picked in Blind 75) | Algo: Dynamic Programming
- Easy 110. Balanced Binary Tree
- Easy 121. Best Time to Buy and Sell Stock (picked in Blind 75)
- Easy 125. Valid Palindrome (picked in Blind 75) | Algo: Regular Expressions, Two-Pointers Technique, String Manipulation
- Easy 141. Linked List Cycle (picked in Blind 75) | Algo: Floyd's Cycle Finding (Two-Pointers Technique)
- Easy 226. Invert Binary Tree (picked in Blind 75)
- Easy 232. Implement Queue using Stacks
- Easy 242. Valid Anagram (picked in Blind 75)
- Easy 278. First Bad Version Algo: Binary Search Algo (Divide and Conquer)
- Easy 383. Ransom Note
- Easy 409. Longest Palindrome
- Easy 704. Binary Search
- Easy 733. Flood Fill
- Medium 235. Lowest Common Ancestor of a Binary Search Tree (picked in Blind 75)
- Easy 13. Roman to Integer
- Easy 14. Longest Common Prefix
- Easy 67. Add Binary
- Easy 100. Same Tree
- Easy 104. Maximum Depth of Binary Tree (picked in Blind 75) | Algo: Depth-First Search
- 🌱 Easy 136. Single Number | Algo: Bit Manipulation (XOR)
- Easy 169. Majority Element Algo: Moore Voting Algo
- Easy 191. Number of 1 Bits | Algo: Bit Manipulation
- Easy 206. Reverse Linked List (picked in Blind 75)
- Easy 217. Contains Duplicate
- Easy 234. Palindrome Linked List | Algo: Two-Pointers Technique (Fast & Slow Pointers)
- Easy 252. Meeting Rooms
- 🌱 Easy 338. Counting Bits | Algo: Dynamic Programming (Bit Manipulation)
- Easy 543. Diameter of Binary Tree | Algo: Depth-First Search; DS: Python's Mutable Objects (list, dict, set)
- 🌱 Easy 844. Backspace String Compare | Algo: Two-Pointers Technique
- ⭐️ Easy 876. Middle of the Linked List
- Easy 9. Palindrome Number | Algo: Reverse Integer
- Easy 101. Symmetric Tree | Algo: Depth-First Search, Breadth-First Search
- Easy 108. Convert Sorted Array to Binary Search Tree | Algo: Depth-First Search
- Easy 190. Reverse Bits (picked in Blind 75) | Algo: Bit Manipulation
- Easy 268. Missing Number (picked in Blind 75) | Algo: Bit Manipulation (XOR)
- Easy 283. Move Zeroes | Algo: Two-Pointers Technique
- Easy 572. Subtree of Another Tree (picked in Blind 75) | Algo: Depth-First Search
- Easy 977. Squares of a Sorted Array
- Medium 3. Longest Substring Without Repeating Characters (picked in Blind 75) | Algo: Sliding Window Technique
- Medium 53. Maximum Subarray (picked in Blind 75) | Algo: Kadane's Algo
- Medium 57. Insert Interval (picked in Blind 75)
- Medium 542. 01 Matrix | Algo: Multi-Source Breadth-First Search
- Medium 973. K Closest Points to Origin | Algo & DS: Heap Sort
- ⭐️ Medium 15. 3Sum (picked in Blind 75) | Algo: Two-Pointer Technique and Dictionary (Hashmap); DS: Hashing
- ⭐️ Medium 98. Validate Binary Search Tree (picked in Blind 75) | Algo: Depth-First Search
- Medium 102. Binary Tree Level Order Traversal (picked in Blind 75) | Algo: Breadth-First Search
- Medium 133. Clone Graph (picked in Blind 75) | Algo: Breadth-First Search
- Medium 150. Evaluate Reverse Polish Notation
- ⭐️ Medium 155. Min Stack | DS: Stack
- Medium 200. Number of Islands (picked in Blind 75) | Algo: Depth-First Search
- ⭐️ Medium 207. Course Schedule (picked in Brind 75) | Algo: Depth-First Search
- Medium 208. Implement Trie (Prefix Tree) | DS: Trie Tree
- Medium 238. Product of Array Except Self (picked in Blind 75)
- ⭐️ Medium 322. Coin Change (picked in Blind 75) | Algo: Dynamic Programming
- ⭐️ Medium 33. Search in Rotated Sorted Array (picked in Blind 75)
- ⭐️ Medium 39. Combination Sum | Algo: Backtracking
- Medium 46. Permutations | Algo: Backtracking
- Medium 56. Merge Intervals (picked in Blind 75)
- Medium 75. Sort Colors | Algo: Dutch National Flag
- Medium 139. Word Break (picked in Blind 75) | Algo: Dynamic Programming
- Medium 236. Lowest Common Ancestor of a Binary Tree | Algo: Depth-First Search
- ⭐️ Medium 721. Accounts Merge | DS: Disjoint Set Union (DSU or Union–Find Data Structure)
- ⭐️ Medium 981. Time Based Key-Value Store | Algo: Binary Search
- Medium 994. Rotting Oranges | Algo: Breadth-First Search
- ⭐️ Medium 5. Longest Palindromic Substring (picked in Blind 75) | Algo: Expand Around Center & Two-Pointers Techniques
- ⭐️ Medium 8. String to Integer (atoi) | DS: Overflow Handling
- Medium 11. Container With Most Water (picked in Blind 75)
- Medium 17. Letter Combinations of a Phone Number
- Medium 54. Spiral Matrix (picked in Blind 75)
- Medium 62. Unique Paths (picked in Blind 75) | Algo: Dynamic Programming
- Medium 78. Subsets
- Medium 79. Word Search (picked in Blind 75) | Algo: Depth-First Search
- ⭐️ Medium 105. Construct Binary Tree from Preorder and Inorder Traversal (picked in Blind 75) | Algo: Preorder & Inorder Traversal
- Medium 199. Binary Tree Right Side View | Algo: Breadth-First Search
- ⭐️ Medium 416. Partition Equal Subset Sum | Algo: Dynamic Programming
- 🌱 Medium 31. Next Permutation
- Medium 36. Valid Sudoku | DS: Hash Table
- ⭐️ Medium 134. Gas Station | Algo: Greedy Approach
- ⭐️ Medium 146. LRU Cache | DS: Doubly Linked List
- Medium 198. House Robber (picked in Blind 75) | Algo: Dynamic Programming
- Medium 230. Kth Smallest Element in a BST (picked in Blind 75) | Algo: Inorder Traversal
- Medium 310. Minimum Height Trees | Algo: Centroid Decomposition & Pruning; DS: Adjacency List
- Medium 438. Find All Anagrams in a String | Algo: Fixed-Size Sliding Window; DS: Hash Table
- ⭐️ Medium 621. Task Scheduler | Algo: Greedy Approach; DS: Hash Table
- Medium 739. Daily Temperatures | Algo: Monotonic Stack
- Medium 19. Remove Nth Node From End of List (picked in Blind 75) | Algo: Two-Pointers Technique (Fast & Slow Pointers)
- Medium 49. Group Anagrams (picked in Blind 75) | DS: Hash Table
- Medium 152. Maximum Product Subarray (picked in Blind 75) | Algo: Dynamic Programming
- 🌱 Medium 211. Design Add and Search Words Data Structure (picked in Blind 75) | DS: Trie Tree
- Medium 261. Graph Valid Tree | Algo: Depth-First Search; DS: Union-Find (Disjoint Set)
- Medium 287. Find the Duplicate Number
- 🌱 Medium 300. Longest Increasing Subsequence (picked in Blind 75) | Algo: Dynamic Programming & Binary Search
- Medium 417. Pacific Atlantic Water Flow
- Medium 692. Top K Frequent Words
- Medium 1730. Shortest Path to Get Food
- Medium 24. Swap Nodes in Pairs
- Medium 113. Path Sum II
- Medium 128. Longest Consecutive Sequence
- Medium 189. Rotate Array
- Medium 210. Course Schedule II
- Medium 328. Odd Even Linked List
- Medium 394. Decode String
- Medium 424. Longest Repeating Character Replacement
- Medium 525. Contiguous Array
- Medium 658. Find K Closest Elements
- Medium 662. Maximum Width of Binary Tree
- Medium 2. Add Two Numbers
- Medium 22. Generate Parentheses
- Medium 55. Jump Game
- Medium 148. Sort List
- Medium 285. Inorder Successor in BST
- Medium 323. Number of Connected Components in an Undirected Graph
- ⭐️ Medium 528. Random Pick with Weight | Algo: Binary Search; DS: Prefix Sum Array
- Medium 560. Subarray Sum Equals K
- Medium 735. Asteroid Collision
- Medium 1197. Minimum Knight Moves
- Medium 48. Rotate Image
- Medium 50. Pow(x, n) | Algo: Exponentiation by Squaring
- Medium 74. Search a 2D Matrix
- Medium 91. Decode Ways
- Medium 103. Binary Tree Zigzag Level Order Traversal
- Medium 179. Largest Number
- ⭐️ Medium 215. Kth Largest Element in an Array | Algo: Quickselect (Fastest in Average Cases), DS: Heap (Good in All Cases)
- Medium 221. Maximal Square
- Medium 253. Meeting Rooms II
- Medium 362. Design Hit Counter
- Medium 437. Path Sum III
- Medium 7. Reverse Integer
- Medium 16. 3Sum Closest
- Medium 61. Rotate List
- Medium 73. Set Matrix Zeroes
- Medium 143. Reorder List
- Medium 153. Find Minimum in Rotated Sorted Array
- ⭐️ Medium 227. Basic Calculator | DS: Stack
- Medium 271. Encode and Decode Strings
- Medium 787. Cheapest Flights Within K Stops
- Medium 863. All Nodes Distance K in Binary Tree
- Medium 377. Combination Sum IV
- Medium 380. Insert Delete GetRandom O(1)
- Medium 435. Non-overlapping Intervals
- Hard 42. Trapping Rain Water | Algo: Two-Pointer Technique
- Hard 76. Minimum Window Substring (picked in Blind 75) | Algo: Sliding Window; DS: Hash Table
- ⭐️ Hard 127. Word Ladder | Algo: Breadth-First Search; DS: Queue, Hash Table
- Hard 224. Basic Calculator
- ⭐️ Hard 295. Find Median from Data Stream (picked in Blind 75) | DS: Min & Max Heaps (Priority Queue)
- Hard 297. Serialize and Deserialize Binary Tree (picked in Blind 75) | Algo: Breadth-First Search; DS: Queue
- Hard 4. Median of Two Sorted Arrays
- Hard 23. Merge k Sorted Lists (picked in Blind 75) | DS: Min Heap (Priority Queue)
- Hard 32. Longest Valid Parentheses
- ⭐️ Hard 84. Largest Rectangle in Histogram | DS: Stack
- Hard 124. Binary Tree Maximum Path Sum
- Hard 329. Longest Increasing Path in a Matrix
- Hard 895. Maximum Frequency Stack
- ⭐️ Hard 1235. Maximum Profit in Job Scheduling | Algo: Binary Search, Dynamic Programming
- Hard 212. Word Search II
- Hard 239. Sliding Window Maximum
- Hard 269. Alien Dictionary
- Hard 336. Palindrome Pairs
- Hard 588. Design In-Memory File System
- Hard 759. Employee Free Time
- Hard 815. Bus Routes
- Hard 25. Reverse Nodes in k-Group
- Hard 37. Sudoku Solver
- Hard 41. First Missing Positive
- Hard 51. N-Queens
- Hard 632. Smallest Range Covering Elements from K Lists
- Easy 346. Moving Average from Data Stream
- Easy 408. Valid Word Abbreviation
- Easy 680. Valid Palindrome II | Algo: Two-Pointer Technique
- Easy 938. Range Sum of BST
- Medium 2. Add Two Numbers | Algo: Carry Management
- ⭐️ Medium 71. Simplify Path
- Medium 129. Sum Root to Leaf Numbers
- Medium 138. Copy List with Random Pointer | DS: Linked List
- Medium 314. Binary Tree Vertical Order Traversal | Algo: Breadth-First Search (BFS), DS: Queue
- Medium 339. Nested List Weight Sum
- Medium 426. Convert Binary Search Tree to Sorted Doubly Linked List
- ⭐️ Medium 457. Circular Array Loop | Algo: Floyd's Cycle Finding (Two-Pointers Technique)
- Medium 708. Insert into a Sorted Circular Linked List
- Medium 763. Partition Labels | Algo: Two-Pointer Technique, Dynamic Sliding Window, Greedy Method
- Medium 791. Custom Sort String
- Medium 841. Keys and Rooms
- Medium 921. Minimum Add to Make Parentheses Valid
- ⭐️ Medium 1011. Capacity To Ship Packages Within D Days | Algo: Binary Search
- Medium 1249. Minimum Remove to Make Valid Parentheses | DS: Stack
- Medium 1570. Dot Product of Two Sparse Vectors
- Medium 1650. Lowest Common Ancestor of a Binary Tree III | Algo: Depth-First Search
- Medium 1762. Buildings with an Ocean View | DS: Monotonic Stack
- Hard 354. Russian Doll Envelopes
- ⭐️ Hard 691. Stickers to Spell Word | Algo: DFS; DS: DFS Function Memoization, Counter & Set Operations
- Medium 912. Sort an Array | Algo: Quick Sort, Merge Sort, Heap Sort, Counting Sort