This repository contains solutions to LeetCode problems, implemented in Python.
Each solution has unit tests to validate its functionality. Test cases are generated based on the input constraints.
Problems are selected from the roadmap by NeetCode.
Currently, I have solved 100 questions.
- Arrays & Hashing
- Stack
- Two Pointers
- Binary Search
- Sliding Window
- Linked Lists
- Trees
- Tries
- Backtracking
- Heap / Priority Queue
- Graphs
- 1D Dynamic Programming
- Intervals
- Greedy
- Advanced Graphs
- 2D Dynamic Programming
- Bit Manipulation
- Math & Geometry
- Implementation of Data Structures
1 Contains Duplicate - Unit Tests
3 Two Sum - Unit Tests
5 Top K Frequent Elements - Unit Tests
6 Product of Array Except Self - Unit Tests
7 Longest Consecutive Sequence - Unit Tests
8 Encode and Decode Strings - Unit Tests
10 Valid Parentheses - Unit Tests
11 Min Stack - Unit Tests
12 Evaluate Postfix Expression - Unit Tests
13 Valid Palindrome - Unit Tests
14 Container With Most Water - Unit Tests
15 Three Sum - Unit Tests
99 Two Sum II - Input Sorted - Unit Tests
16 Binary Search - Unit Tests
17 Find Minimum in Rotated Sorted Array - Unit Tests
18 Search in Rotated Sorted Array - Unit Tests
19 Search a 2D Matrix - Unit Tests
20 Best Time to Buy and Sell Stock - Unit Tests
21 Longest Substring Without Repeating Characters - Unit Tests
22 Longest Repeating Character Replacement - Unit Tests
73 Min Window Substring - Unit tests
23 Reverse Linked List - Unit Tests
24 Merge Two Sorted Lists - Unit Tests
25 Linked List Cycle - Unit Tests
26 Reorder List - Unit Tests
27 Remove Nth Node From End of List - Unit Tests
28 Merge k Sorted Lists - Unit Tests
29 Invert Binary Tree - Unit Tests
30 Maximum Depth of Binary Tree - Unit Tests
31 Diameter of Binary Tree - Unit Tests
32 Same Tree - Unit Tests
33 Subtree of Another Tree - Unit Tests
34 Balanced Binary Tree - Unit Tests
35 Lowest Common Ancestor of a BST - Unit Tests
36 Binary Tree Level Order Traversal - Unit Tests
37 Validate Binary Search Tree - Unit Tests
38 Construct Binary Tree from Preorder and Inorder Traversal - Unit Tests
39 Kth Smallest Element in a BST - Unit Tests
40 Binary Tree Maximum Path Sum - Unit Tests
41 Binary Tree Right Side View - Unit Tests
42 Implement Trie (Prefix Tree) - Unit Tests
91 Add and Search Word DS (Trie) - Unit Tests
92 Word Search II - Unit Tests
43 Generate All Permutations - Unit Tests
44 Number of Islands - Unit Tests
45 Subsets - Unit Tests
46 Combination Sum - Unit Tests
47 Combination Sum II - Unit Tests
48 Letter Combinations of a Phone Number - Unit Tests
49 Word Search - Unit Tests
50 Subsets II - Unit Tests
51 Climbing Stairs - Unit Tests
52 House Robber - Unit Tests
53 House Robber II - Unit Tests
54 Longest Palindromic Substring - Unit Tests
55 Coin Change - Unit Tests
56 Min Cost Climbing Stairs - Unit Tests
57 Word Break - Unit Tests
58 Palindromic Substrings - Unit Tests
59 Longest Palindromic Substring - Unit Tests
89 Max Product Subarray - Unit Tests
90 Decode Ways - Unit Tests
60 Reverse Bits - Unit Tests
61 Number of 1 Bits - Unit Tests
62 Single Number - Unit Tests
74 Missing Number - Unit Tests
80 Counting Bits - Unit Tests
81 Sum of Two Integers - Unit Tests
63 Kth Largest Element in a Stream - Unit Tests
64 Kth Largest Element in an Array - Unit Tests
65 Last Stone Weight - Unit Tests
66 Find Median from Data Stream - Unit Tests
100 K Closest Points to Origin - Unit Tests
67 Maximum Subarray - Unit Tests
68 Jump Game - Unit Tests
69 Jump Game II - Unit Tests
70 Clone Graph - Unit Tests
71 Pacific Atlantic Water Flow - Unit Tests
72 Graph Valid Tree - Unit Tests
75 Course Schedule - Unit Tests
76 Number of Connected Components in an Undirected Graph - Unit Tests
93 Max Area Island - Unit Tests
94 Walls and Gates - Unit Tests
95 Rotting Oranges - Unit Tests
96 Surrounded Regions - Unit Tests
97 Course Schedule II - Unit Tests
98 Redundant Connection - Unit Tests
82 Insert Interval - Unit Tests
83 Merge Intervals - Unit Tests
84 Non-overlapping Intervals - Unit Tests
85 Meeting Rooms - Unit Tests
86 Meeting Rooms II - Unit Tests
87 Unique Paths - Unit Tests
88 Longest Common Subsequence - Unit Tests
77 Rotate Image - Unit Tests
78 Spiral Matrix - Unit Tests
79 Set Matrix Zeroes - Unit Tests
00 Binary Tree
00 Linked List
00 Min Heap
00 Trie
00 Min Stack