/LC-Study-Plan

My LeetCode Python solutions

Primary LanguagePythonMIT LicenseMIT

LeetCode study plan

Language  License  Progress  Visitors

My solution for LeetCode problems using Python.

Topics

Techniques

Bit Manipulation

# Title Level Time Space Tags
136 Single Number Easy . .
190 Reverse Bits Easy . .
191 Number of 1 Bits Easy O(1) O(1) Kernighan’s Algorithm
201 Bitwise AND of Numbers Range Medium O(1) O(1)
231 Power of Two Easy . .
Back to Top

Two Pointers

# Title Level Time Space Tags
11 Container With Most Water Medium O(n) O(1) TwoPointers
15 3Sum Medium O(n) O(1) TwoPointers
125 Valid Palindrome Easy O(n) O(1) TwoPointers
167 Two Sum II - Input array is sorted Medium O(n) O(1) HashMap, TwoPointers
283 Move Zeroes Easy O(n) O(1) TwoPointers
344 Reverse String Easy O(n) O(1) TwoPointers
581 Shortest Unsorted Continuous Subarray Medium O(n) O(1) TwoPointers
647 Palindromic Substrings Medium O(n^2) O(1) TwoPointers
844 Backspace String Compare Easy O(n) O(1) TwoPointers backwards
905 Sort Array By Parity Easy O(n) O(1)
977 Squares of a Sorted Array Easy O(n) O(1) TwoPointers
1695 Maximum Erasure Value Medium O(n) O(n) TwoPointers
Back to Top

Programming paradigms

Backtracking

# Title Level Time Space Tags
17 Letter Combinations of a Phone Number Medium O(n * 4^n) O(1) Backtraking
22 Generate Parentheses Medium O(2^(n+1)) O(n) Backtraking
39 Combination Sum Medium O(2^t) O(1) DFS
40 Combination Sum II Medium O(n^2) O(n^2) Backtraking
46 Permutations Medium . .
47 Permutations II Medium O(n * 2^n) O(n) DFS
51 N-Queens Hard O(n^n) O(n*n)
52 N-Queens Hard O(n^n) O(1)
77 Combinations Medium . .
78 Subsets Medium O(n*2^n) O(n*2^n)
79 Word Search Medium . .
90 Subsets Medium O(n*2^n) O(n*2^n)
216 Combination Sum III Medium O(k * C(n, k)) O(k) DFS
784 Letter Case Permutation Medium . .
Back to Top

Dynamic Programming

# Title Level Time Space Tags
45 Jump Game II Medium O(n^2) O(n)
62 Unique Paths Medium O(n * m) O(n)
70 Climbing Stairs Easy . .
72 Edit Distance Hard O(n * m) O(n * m)
120 Triangle Medium . .
198 House Robber Medium O(n) O(1)
213 House Robber II Medium O(n) O(1)
300 Longest Increasing Subsequence Medium O(n^2) O(n)
303 Range Sum Query - Immutable Easy O(n) init, O(1) query O(n) prefix_sum
304 Range Sum Query 2D - Immutable Medium O(n^2) init, O(1) query O(n^2) prefix_sum
307 Range Sum Query - Mutable Medium . .
322 Coin Change Medium O(m * n) O(m)
343 Integer Break Medium O(n^2) O(n)
413 Arithmetic Slices Medium O(n) O(1)
583 Delete Operation for Two Strings Medium O(m * n) O(m * n)
673 Number of Longest Increasing Subsequence Medium O(n^2) O(n)
1143 Longest Common Subsequence Medium O(n * m) O(n * m)
1641 Count Sorted Vowel Strings Medium O(n) O(1)
1658 Minimum Operations to Reduce X to Zero Medium O(n) O(n) prefix_sum
Back to Top

Greedy

# Title Level Time Space Tags
42 Trapping Rain Water Hard . .
55 Jump Game Medium O(n) O(1)
134 Gas Station Medium . .
Back to Top

Memoization

# Title Level Time Space Tags
518 Coin Change 2 Medium O(m * n) O(m * n) DFS
Back to Top

Data Structures

Array

# Title Level Time Space Tags
26 Remove Duplicates from Sorted Array Easy . .
121 Best Time to Buy and Sell Stock Easy . . SlidingWindow
128 Longest Consecutive Sequence O(α(n)) O(n) DSU, HashSet, HashMap
169 Majority Element Easy . .
189 Rotate Array Medium . .
209 Minimum Size Subarray Sum Medium O(n) O(1) TwoPointers
215 Kth Largest Element in an Array Medium . .
238* Product of Array Except Self Medium O(n) O(1)
384 Shuffle an Array Medium O(n) O(n) Fisher-Yates
424 Longest Repeating Character Replacement Medium O(n) O(1) SlidingWindow
704 Binary Search Easy . .
713 Subarray Product Less Than K Medium O(n) O(1) TwoPointers
807 Max Increase to Keep City Skyline Medium . .
986 Interval List Intersections Medium O(n+m) O(1) TwoPointers
1337 The K Weakest Rows in a Matrix Easy . .
Back to Top

Binary Heap

# Title Level Time Space Tags
347 Top K Frequent Elements Medium O(n) O(n)
621 Task Scheduler Medium O(n) O(1)
630 Course Schedule III Hard O(n log n) O(n)
703 Kth Largest Element in a Stream Easy . .
1046 Last Stone Weight Easy . .
Back to Top

Graph

# Title Level Time Space Tags
130 Surrounded Regions Medium O(m*n) O(1) DFS
133 Clone Graph Medium . . DFS
200 Number of Island Medium . . DFS, BFS
207 Course Schedule Medium . . DFS cycle
210 Course Schedule II Medium . .
329 Longest Increasing Path in a Matrix hard O(m * n) O(m * n) DFS and memoization
417 Pacific Atlantic Water Flow Medium . . DFS and Sets
542 01 Matrix Medium . . BFS, DP
547 Number of Provinces Medium . . DFS
695 Max Area of Island Medium . .
733 Flood Fill Easy . .
797 All Paths From Source to Target Medium . .
841 Keys and Rooms Medium . .
934 Shortest Bridge Medium . . BFS multi source and DFS
994 Rotting Oranges Medium . . BFS multi source
997 Find the Town Judge Easy . .
1020 Number of Enclaves Medium . . DFS
1091 Shortest Path in Binary Matrix Medium . . BFS
1162 As Far from Land as Possible Medium . . BFS multi source
1192 Critical Connections in a Network Hard O(v+e) O(v+e) Tarjan
1254 Number of Closed Islands Medium . . DFS 2 pass
1319 Number of Operations to Make Network Connected Medium . . DFS
1791 Find Center of Star Graph Easy . .
1905 Count Sub Islands Medium . .
1926 Nearest Exit from Entrance in Maze Medium . .
1971 Find if Path Exists in Graph Easy . . DFS_(i, r) and BFS_(i, r)
Back to Top

Hash Table

# Title Level Time Space Tags
1 Two Sum Easy O(n) O(n)
13 Roman to Integer Easy . .
36 Valid Sudoku Medium . .
49 Group Anagrams Medium O(n*m) O(n*m)
202 Happy Number Easy O(?) O(?)
Back to Top

Linked List

# Title Level Time Space Tags
2 Add Two Numbers Medium . .
19 Remove Nth Node From End of List Medium O(n) O(1) TwoPointers
21 Merge Two Sorted Lists Easy . .
82 Remove Duplicates from Sorted List II Medium O(n) O(1) TwoPointers
138 Copy List with Random Pointer Medium . .
141 Linked List Cycle Easy . .
143 Reorder List Medium O(n) O(1)
160 Intersection of Two Linked Lists Easy . .
876 Middle of the Linked List Easy . . TwoPointers
Back to Top

Queue

# Title Level Time Space Tags
239 Sliding Window Maximum Hard . . MaxQueue
341 Flatten Nested List Iterator Medium . . Recursion
950 Medium O(n) O(n)
1438 Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit Medium . . MaxQueue
Back to Top

Stack

# Title Level Time Space Tags
20 Valid Parentheses Easy . .
32 Longest Valid Parentheses Hard O(n) O(n)
71 Simplify Path Medium . .
84 Largest Rectangle in Histogram Hard O(n) O(1)
150 Evaluate Reverse Polish Notation Medium . .
155 Min Stack Easy . .
224 Basic Calculator Hard . .
225 Implement Stack using Queues Easy . .
739 Daily Temperatures Medium O(n) O(m) MinStack
Back to Top

String

# Title Level Time Space Tags
3 Longest Substring Without Repeating Characters Medium . . Sliding Window
5 Longest Palindromic Substring Medium . .
8 String to Integer (atoi) Medium . .
91 Decode Ways Medium O(n) O(1) dfs, dp
139 Word Break Medium O(n*m) O(n) dp
208 Implement Trie (Prefix Tree) Medium O(n) O(n*m) Trie
438 Find All Anagrams in a String Medium O(n) O(m) HashMap, TwoPointers
557 Reverse Words in a String III Easy . .
567 Permutation in String Medium . . Sliding Window
745 Prefix and Suffix Search Hard O(k*n) O(k*n) Trie
771 Jewels and Stones Easy . .
820 Short Encoding of Words Medium O(k*n) O(k*n) Trie
1344 Angle Between Hands of a Clock Medium . .
1689 Partitioning Into Minimum Number Of Deci-Binary Numbers Medium O(n) O(1)
Back to Top

Tree

# Title Level Time Space Tags
94 Binary Tree Inorder Traversal Easy . .
98 Validate Binary Search Tree Medium . .
101 Symmetric Tree Easy . .
102 Binary Tree Level Order Traversal Medium . . BFS
104 Maximum Depth of Binary Tree Easy . .
105 Construct Binary Tree from Preorder and Inorder Traversal Medium . .
116 Populating Next Right Pointers in Each Node Easy . .
117 Populating Next Right Pointers in Each Node II Easy O(n) O(n) BFS
211 Design Add and Search Words Data Structure Medium . .
212 Word Search II Medium . .
230 Kth Smallest Element in a BST Medium O(n) O(n) InOrder
236 Lowest Common Ancestor of a Binary Tree Medium . .
572 Subtree of Another Tree Easy O(n * m) O(1) Recursion
617 Merge Two Binary Trees Medium . .
968 Binary Tree Cameras Hard O(n) O(h) DFS
1379 Find a Corresponding Node of a Binary Tree in a Clone of That Tree Medium O(n) O(n) DFS
Back to Top

Algorithms

Binary Search

# Title Level Time Space Tags
33 Search in Rotated Sorted Array Medium O(log n) O(1)
35 Search Insert Position Easy . .
74 Search a 2D Matrix Medium O(log n) O(1)
153 Find Minimum in Rotated Sorted Array Medium O(log n) O(1)
162 Find Peak Element Medium O(log n) O(1)
278 First Bad Version Easy . .
374 Guess Number Higher or Lower Easy O(log n) O(1)
669 Trim a Binary Search Tree Medium O(n) O(n)
704 Binary Search Easy . .
Back to Top

Design

# Title Level Time Space Tags
146 LRU Cache Medium . .
Back to Top

Sorting

# Title Level Time Space Tags
56 Merge Intervals O(nlogn) O(1) Intervals
57 Insert Interval Medium O(n) O(1) Intervals
88 Merge Sorted Array Easy . .
435 Non-overlapping Intervals Medium O(nlogn) O(1) Intervals
1851 Minimum Interval to Include Each Query Hard O(nlogn + qlogq) O(n) MinHeap
Back to Top

Path planning

# Title Level Time Space Tags
743 Network Delay Time Medium O(V*logE) O(E) Djikstra
Back to Top