Skip to content

Leetcode solutions in python, with time and complexity analysis and documentation.

Notifications You must be signed in to change notification settings

clintjohnsn/ds-algo

Repository files navigation

Leetcode Solutions

Regularly updated Leetcode solutions in python. Multiple approaches and solutions for every problem, along with time and space complexity analysis and comments. Focus on data structures and algorithms.

Problem List

No Problem Source Difficulty Solution Topic
1 Count and Say LeetCode #38 easy solution Arrays
2 Power(x,n) LeetCode #50 easy solution Arrays
3 Two Sum LeetCode #167 easy solution Arrays
4 Group Anagrams LeetCode #49 easy solution Arrays
5 Remove Duplicates LeetCode #26 easy solution Arrays
6 Pivot element/Equilibrium element LeetCode #724 easy solution Arrays
7 Array Intersection LeetCode 349 easy solution Arrays
8 Last stone weight LeetCode #1046 easy solution Arrays
9 Majority Element Leetcode #169 easy solution Arrays
10 Best time to buy and sell stock Leetcode #121 easy solution Arrays
11 Remove Duplicates Leetcode #26 easy solution Arrays
12 Reverse array in groups Leetcode #541 easy solution Arrays
13 Sort Colors Leetcode #75 easy solution Arrays
14 Squares of sorted array Leetcode #977 easy solution Arrays
15 Maximum difference between increasing elements Leetcode #2016 easy solution Arrays
16 Move zeroes Leetcode #283 easy solution Arrays
17 Missing Number Leetcode #268 easy solution Arrays
18 Pascal's Triangle Leetcode #118 easy solution Arrays
19 Triplet sum Leetcode #15 easy solution Arrays
20 Three sum closest Leetcode #16 medium solution Arrays
21 Insert interval Leetcode #57 medium solution Arrays
22 Rotate Function Leetcode #396 medium solution Arrays
23 Maximum Subarray Leetcode #53 medium solution Arrays
24 Merge Intervals Leetcode #56 medium solution Arrays
25 Next Greater Element Leetcode #496 medium solution Arrays
26 Partition Labels Leetcode #763 medium solution Arrays
27 Product of Array except self Leetcode #238 medium solution Arrays
28 Rotate Array Leetcode #189 medium solution Arrays
29 Sliding Window Maximum Leetcode #239 medium solution Arrays
30 Stock Span Leetcode #901 medium solution Arrays
31 K Subarray Sum Leetcode #560 medium solution Arrays
32 Ugly Number Leetcode #264 medium solution Arrays
33 Increasing Triplet Subsequence Leetcode #334 pro solution Arrays
34 Number of 1 bits Leetcode #191 easy solution Bit Manipulation
35 reverse bits Leetcode #190 easy solution Bit Manipulation
36 single number Leetcode #136 easy solution Bit Manipulation
37 basic caeser cypher easy solution Brute Force
38 Good pairs Leetcode #1512 easy solution Brute Force
39 Find closest primes easy solution Brute Force
40 Power function easy solution Brute Force
41 Submatrix Sum easy solution Brute Force
42 Disjoint Set easy solution Disjoint Sets
43 Most stones removed Leetcode #947 medium solution Disjoint Sets
44 Number of Provinces Leetcode #547 medium solution Disjoint Sets
45 Climbing Stairs Leetcode #70 easy solution Dynamic Programming
46 Fibonacci easy solution Dynamic Programming
47 Min Cost Climbing Stairs Leetcode #746 easy solution Dynamic Programming
48 Assembly line scheduling medium solution Dynamic Programming
49 Coin Change Leetcode #322 medium solution Dynamic Programming
50 Cutting Rod medium solution Dynamic Programming
51 Edit Distance Leetcode #72 medium solution Dynamic Programming
52 House Robber Leetcode #198 medium solution Dynamic Programming
53 Knapsack Problem medium solution Dynamic Programming
54 Longest Common Subsequence Leetcode #1143 medium solution Dynamic Programming
55 Max sum subsequence medium solution Dynamic Programming
56 Longest Common Subsequence Leetcode #1143 medium solution Dynamic Programming
57 Min path triangle Leetcode #120 medium solution Dynamic Programming
58 Unique Paths Leetcode #120 medium solution Dynamic Programming
59 Partition Equal Subset Sum Leetcode #416 medium solution Dynamic Programming
60 Maximum product subarray Leetcode #152 pro solution Dynamic Programming
61 Breadth First Search easy solution Graphs
62 Depth First Search easy solution Graphs
63 Flood Fill easy solution Graphs
64 Number of Islands Leetcode #200 medium solution Graphs
65 Max Area of Island Leetcode #1152 medium solution Graphs
66 01 Matrix Leetcode #542 medium solution Graphs
67 Pacific atlantic water flow Leetcode #417 medium solution Graphs
68 Rotting Oranges Leetcode #994 medium solution Graphs
69 Valid Sudoku Leetcode #36 medium solution Graphs
70 Find the Celebrity Leetcode #277 pro solution Graphs
71 Detect Cycle pro solution Graphs
72 Topological Sort pro solution Graphs
73 Longest Palindrome Leetcode #409 easy solution Hashmaps
74 Word Pattern Leetcode #290 easy solution Hashmaps
75 Anagrams medium solution Hashmaps
76 Frequent Queries medium solution Hashmaps
77 LRU medium solution Hashmaps
78 Task Scheduler Leetcode #621 medium solution Hashmaps
79 Bus Routes Leetcode #815 pro solution Hashmaps
80 LinkedList addition easy solution Linked Lists
81 Linked List Intersection Leetcode #160 easy solution Linked Lists
82 Odd Even Linked List Leetcode #328 easy solution Linked Lists
83 Palindrome Linked List Leetcode #234 easy solution Linked Lists
84 Remove Elements in Linked List Leetcode #203 easy solution Linked Lists
85 Remove Node Linked List Leetcode #19 easy solution Linked Lists
86 Swapping Nodes Linked List Leetcode #1721 easy solution Linked Lists
87 Linked List Cycle Leetcode #142 medium solution Linked Lists
88 Grouped Reverse Linked List Leetcode #25 medium solution Linked Lists
89 Flatten Multilevel Linked List Leetcode #430 pro solution Linked Lists
90 Reverse Integer Leetcode #7 easy solution Math
91 Hourglass Matrix easy solution Matrices
92 Positional Elements in a Matrix easy solution Matrices
93 Rotate Image Leetcode #48 medium solution Matrices
94 Set Matrix Zeroes Leetcode #73 medium solution Matrices
95 Spiral Matrix Leetcode #54 medium solution Matrices
96 Where will the ball fall? Leetcode #1706 medium solution Matrices
97 Binary Search easy solution Search
98 Search 2D matrix Leetcode #240 medium solution Search
99 Minimum Rotated Array Leetcode #153 medium solution Search
100 Search sorted matrix Leetcode #74 medium solution Search
101 Sorting Algoritms easy solution Sorting
102 Sorting Linked Lists medium solution Sorting
103 Sliding Median medium solution Sorting
104 K Large elements in Array Leetcode #215 pro solution Sorting
105 3-way Partition pro solution Sorting
106 FIFO Queue using Stack Leetcode #232 easy solution Stacks
107 Valid Parenthesis Leetcode #20 easy solution Stacks
108 Asteroid collision Leetcode #735 medium solution Stacks
109 Calculator Leetcode #227 medium solution Stacks
110 Decode String Leetcode #394 medium solution Stacks
111 Remove Adjacent Duplicates Leetcode #1209 medium solution Stacks
112 Min Stack Leetcode #155 pro solution Stacks
113 Valid Anagram Leetcode #242 easy solution Strings
114 Backspace String Compare Leetcode #844 easy solution Strings
115 Longest Common Prefix Leetcode #14 easy solution Strings
116 Multiply Strings Leetcode #43 easy solution Strings
117 Bulls and Cows Leetcode #299 medium solution Strings
118 Repeated DNA sequences Leetcode #187 medium solution Strings
119 K Frequent Words Leetcode #692 medium solution Strings
120 Longest Palindrome Leetcode #2131 medium solution Strings
121 Longest Palindromic Substring Leetcode #5 medium solution Strings
122 Longest repeating char replacement Leetcode #424 medium solution Strings
123 Longest substring without repeating chars Leetcode #3 medium solution Strings
124 Permutation in string Leetcode #567 medium solution Strings
125 Min window substring Leetcode #76 pro solution Strings
126 Smallest window containing another string pro solution Strings
127 Tree BFS easy solution Trees
128 Binary Tree Inorder Traversal easy solution Trees
129 Binary Search Tree easy solution Trees
130 Inorder, Preorder, Postorder DFS easy solution Trees
131 Balanced Binary Tree Leetcode #110 easy solution Trees
132 Binary Tree Diameter Leetcode #543 easy solution Trees
133 Invert Binary Tree Leetcode #226 easy solution Trees
134 Lowest common ancestor BST Leetcode #235 easy solution Trees
135 Merge Binary Trees Leetcode #617 easy solution Trees
136 N-ary tree preorder traversal Leetcode #589 easy solution Trees
137 Same Tree Leetcode #100 easy solution Trees
138 Sorted Array to BST Leetcode #108 easy solution Trees
139 BST iterator implementation Leetcode #173 medium solution Trees
140 Construct Tree from Preorder and Inorder Leetcode #105 medium solution Trees
141 Course Schedule Leetcode #210 medium solution Trees
142 kth smallest BST Leetcode #230 medium solution Trees
143 Longest Univalue Path Leetcode #687 medium solution Trees
144 Path Sum Leetcode #113 medium solution Trees
145 Populate next perfect BST Leetcode #116 medium solution Trees
146 BST side view Leetcode #199 medium solution Trees
147 Trie Implementation Leetcode #208 medium solution Trees
148 Validate BST Leetcode #98 medium solution Trees

About

Leetcode solutions in python, with time and complexity analysis and documentation.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages