Skip to content

yangfut/Leetcode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python/C Solutions for Leetcode

# Title Category Difficulty Solution Time Space
1528 Shuffle String Sort Easy python, c++ O(N) O(N)
350 Intersection of Two Arrays II Hash Table, Two Pointer, Binary Search Easy python O(N) O(N)
206 Reverse Linked List Linked List, Recursion Easy python, c++ O(N) O(1)
1640 Check Array Formation Through Concatenation Array, Hash Table, Sort Easy python O(N) O(N)
957 Prison Cells After N Days Hash Table Medium python, c++ O(1) O(1)
1502 Can Make Arithmetic Progression From Sequence Arrya, Sort Easy python O(NlogN) O(1)
242 Valid Anagram Hash Table, Sort Easy python O(N) O(1)
1450 Number of Students Doing Homework at a Given Time Array Easy python O(N) O(1)
1600 Throne Inheritance Tree, Design Medium python O(N) O(N^2)
1742 Maximum Number of Balls in a Box Array Easy python O(N) O(1)
1054 Distant Barcodes Heap, Sort Medium python O(N) O(N)
1464 Maximum Product of Two Elements in an Array Array Easy python O(N) O(1)
1725 Number Of Rectangles That Can Form The Largest Square Greedy Easy python O(N) O(N)
452 Minimum Number of Arrows to Burst Balloons Greedy, Sort Medium python O(NlogN) O(1)
1403 Minimum Subsequence in Non-Increasing Order Greedy, Sort Easy python O(N) O(1)
1665 Minimum Initial Energy to Finish Tasks Greedy Hard python O(NlogN) O(1)
455 Assign Cookies Greedy Easy python, c++ O(NlogN) O(1)
1138 Alphabet Board Path Hash Table, String Medium python, c++ O(N) O(1)
852 Peak Index in a Mountain Array Binary Search Easy python O(logN) O(1)
1207 Unique Number of Occurrences Hash Table Easy python O(N) O(N)
1122 Relative Sort Array Array, Sort Easy python O(NM) O(N)
1160 Find Words That Can Be Formed by Characters Array, Hash Table Easy python, c++ O(N*M) O(1)
1031 Maximum Sum of Two Non-Overlapping Subarrays Array Medium python O(N) O(1)
1491 Average Salary Excluding the Minimum and Maximum Salary Array, Sort Easy python O(N) O(1)
283 Move Zeroes Array, Two Pointers Easy python O(N) O(1)
445 Add Two Numbers II Linked List Medium python O(N) O(N)
2 Add Two Numbers Linked List Medium python, c++ O(N) O(1)
1254 Number of Closed Islands Depth-first Search Medium python O(NM) O(1)
1507 Reformat Date String Easy python O(1) O(1)
721 Accounts Merge Depth-first Search, Union Find Medium python O(NM) O(NM)
1103 Distribute Candies to People Math Easy python O(N) O(N)
202 Happy Number Hash Table, Math Easy python, c O(1) O(1)
1710 Maximum Units on a Truck Greedy, Hash, Sort Easy python O(N) O(1)
1 Two Sum Array, Hash Easy c, c++ O(N) O(N)
9 Palindrome Number Math Easy python O(N) O(N)
35 Search Insert Position Array, Binary Search Easy python O(logN) O(1)
66 Plus One Array, Math Easy python O(N) O(N)
83 Remove Duplicates from Sorted List Linked List Easy python O(N) O(1)
94 Binary Tree Inorder Traversal Stack, Tree, DFS, Binary Tree Easy python O(N) O(N)
13 Roman to Integer Hash Table, Math, String Easy C++ O(N) O(1)
26 Remove Duplicates from Sorted Array Array, Two Pointers Easy python O(N) O(1)
122 Best Time to Buy and Sell Stock II Array, Dynamic Programming, Gredy Medium python O(N) O(N)
136 Single Number Array, Bit Manipulation Easy c O(N) O(1)
15 3Sum Array, Two Pointer, Sorting Medium python, c++ O(N^2) O(N)
169 Majority Element Array, Hash Table, Divide and Conquer Easy python, c++ O(N) O(1)
1470 Running Sum of 1d Array Array Easy python O(N) O(1)
724 Find Pivot Index Array Easy python, c++ O(N) O(1)
205 Isomorphic Strings Array Easy python, c++ O(N) O(1)
392 Is Subsequence Two Pointers, String, Dynamic Programming Easy python, c++ O(N) O(1)
14 Longest Common Prefix String, Trie Easy python, c++ O(M*N) O(1)
704 Binary Search Array, Binary Search Easy python, c, c++ O(log(N)) O(1)
278 First Bad Version Binary Search, Interfactive Easy pythonc O(log(N)) O(1)
35 Search Instert Position Array, Binary Search Easy python O(log(N)) O(1)
977 Squares of a Sorted Array Array, Two Pointers, Sorting Easy python O(N) O(1)
189 Rotate Array Array, Math, Two Pointers Medium python O(N) O(N)
167 Two Sum II - Input Array Is Sorted Array, Two Pointers, Binary Search Medium python O(N) O(1)
344 Reverse String Two Pointers, String Easy python, c++ O(N) O(1)
557 Reverse Words in a String III Two Pointers, String Easy python O(N^2) O(N)
876 Middle of the Linked List Linked List, Two Pointers Easy c O(N) O(1)
19 Remove Nth Node From End of List Linked List, Two Pointers Medium c, c++ O(N) O(1)
3 Longest Substring Without Repeating Characters Hash Table, String, Sliding Window Medium c, c++ O(N) O(1)
209 Minimum Size Subarray Sum Array, Binary Search, Sliding Window Medium c O(N) O(1)
219 Contains Duplicate II Array, Hash Table, Sliding Window Easy c++ O(N) O(M)
220 Contains Duplicate III Array, Sliding Window, Sorting, Bucket Sort, Ordered Set Hard c++ O(N) O(N)
221 Maximal Square Array, Dynamic Programming, Matrix Medium c++ O(N) O(N)
213 House Robber II Array, Dynamic Programming Medium c++ O(N) O(N)
474 Ones and Zeroes Array, String, Dynamic Programming Medium c++ O(N*M*L) O(N*M)
494 Ones and Zeroes Array, Dynamic Programming, Backtracking Medium c++ O(N*T) O(N*T)
322 Coin Change Array, Dynamic Programming, DFS Medium c++ O(N*M) O(M)
518 Coin Change II Array, Dynamic Programming Medium c++ O(N*M) O(M)
62 Unique Path Array, Dynamic Programming, Combinatorics Medium c++ O(N*M) O(N*M)
63 Unique Path II Array, Dynamic Programming Medium c++ O(N*M) O(N*M)
46 Permutations Array, Backtracking Medium c++ O(N*N!) O(N)
47 Permutations II Array, Backtracking Medium c++ O(N*N!) O(N)
78 Subsets Array, Backtracking, Bit Manipulation Medium c++ O(N*2^N^) O(N)
90 Subsets II Array, Backtracking, Bit Manipulation Medium c++ O(N*2^N^) O(N)
33 Serach in Rotated Sorted Array Array, Binary Search Medium c++ O(log(N)) O(1)
70 Climbing Stairs Math, Dynamic Programming, Memorization Easy c++ O(N) O(N)
27 Remove Elements Array, Two Pointers Easy c++ O(N) O(1)
1796 Second Largest Digit in a String Hash Table, String Easy c++ O(N) O(1)
1540 Can Convert String in K Moves Hash Table, String Easy c++ O(N) O(1)
2465 Numbers of Distinct Averages Array, Hash Table, Two Pointers, Sorting Easy c++ O(N) O(1)
2006 Count Number of Pairs With Absolute Difference K Array, Hash Table Easy c++ O(N) O(N)
100 Same Tree Tree, Depth-First Search, Breadth-First Search, Binary Tree Easy c++ O(1) O(1)
101 Symmetric Tree Tree, Depth-First Search, Breadth-First Search, Binary Tree Easy c++ O(log(N)) O(1)
104 Maximum Depth of Binary Tree Tree, Depth-First Search, Breadth-First Search, Binary Tree Easy c++ O(N) O(N)
108 Convert Sorted Array to Binary Search Tree Array, Divide-And-Conquer, Tree ,Breadth-First Search, Binary Tree Easy c++ O(N) O(N)
110 Balanced Binary Tree Array, Divide-And-Conquer, Tree ,Breadth-First Search, Binary Tree Easy c++ O(N) O(1)
112 Path Sum Tree, Depth-First Search, Breadth-First Search, Binary Tree Easy c++ O(N) O(1)
118 Pascal's Triangle Array, Dynamic Programming Easy c++ O(N^2) O(N^2)
121 Best Time to Buy and Sell Stock Array, Dynamic Programming Easy c++ O(N) O(1)
509 Fibonacci Number Dynamic Programming, Recursion, Memorization Easy c++ O(N) O(N)
122 Best Time to Buy and Sell Stock II Array, Dynamic Programming Medium c++ O(N) O(1)
125 Valid Palindrome Two Pointers, String Easy c++ O(N) O(1)
141 Linked List Cycle Hash Table, Linked List, Two Pointers Easy c++ O(N) O(1)
144 Binary Tree Preorder Traversal Stack, Tree, Detph-First Search, Binary Tree Easy c++ O(N) O(N)
171 Excel Sheet Column Number Math, String Easy c++ O(N) O(1)
168 Excel Sheet Column Title Math, String Easy c++ O(N) O(N)
190 Reverse Bits Divide and Conquer, Bit Manipulation Easy c++ O(1) O(1)
191 Number of 1 Bits Divide and Conquer, Bit Manipulation Easy c++ O(1) O(1)
203 Remove Linked List Elements Linked List, Recursion Easy c++ O(N) O(1)
912 Sort an Array Array, Divide and Conquer, Sorting, Heap (Priority Queue), Merge Sort, Bucket Sort, Radix Sort, Counting Sort Easy c++ O(NLogN) O(N)
217 Contains Duplicate Array, Hash Table, Sorting Easy c++ O(N) O(N)
222 Count Complete Tree Nodes Binary Search, Bit Manipulation, Tree, Binary Tree Easy c++ O(N) O(1)
2215 Find the Difference of Two Arrays Array, Hash Tables Easy c++ O(N) O(N)
1217 Minimum Cost to Move Chips to The Same Position Array, Math, Greedy Easy c++ O(N) O(1)
2578 Split With Minimum Sum Math, Greedy, Sorting Easy c++ O(1) O(1)
46 Permutations Array, Backtracking Medium c++ O(N*N!) O(N)
118 Pascal's Triangle Array, Dynamic Programming Easy c++ O(N^2) O(N^2)
48 Rotate Image Array, Math, Matrix Medium c++ O(N*2) O(1)
136 Single Number Array, Bit Mainulation Easy c++ O(N) O(1)
108 Convert Sorted Array to Binary Search Tree Array, Divide-And-Conquer, Tree ,Breadth-First Search, Binary Tree Easy c++ O(N) O(N)
289 Game of Life Array, Matrix, Simulation Easy c++ O(MN^2) O(MN)
49 Group of Anagrams Array, Hash Table, String, Sorting Medium c++ O(NKLog(K)) O(N)
215 Kth Largest Element in an Array Array, Divide and Conquer, Sorting, Heap(Priority Queue), Quickselect Easy c++ O(NlogK) O(K)
122 Best Time to Buy and Sell Stock II Array, Dynamic Programming, Greedy Medium c++ O(N) O(1)
238 Product of Array Except Self Array, Prefix Sum Medium c++ O(N) O(1)
268 Missing Number Array, Hash Table, Math, Binary Search, Bit Manipulation, Sorting Easy c++ O(N) O(1)
169 Majority Element Array, Hash Table, Divide and Conquer, Sorting, Counting Easy c++ O(N) O(1)
105 Construct Binary Tree from Preorder and Inorder Traversal Array, Hash Table, Divide and Conquer, Tree, Binary Tree Medium c++ O(N) O(N)
347 Top K Frequent Elements Array, Hash Table, Divide and Conquer, Sorting, Heap (Priority Queue), Bucket Sort, Counting, Quickselect Medium c++ O(NLogN) O(N)
378 Kth Smallest Element in a Sorted Matrix Array, Binary Search, Sorting, Heap (Priority Queue), Matrix Medium c++ O(NNlogN) O(1)
75 Sort Colors Array, Two Pointers, Sorting Medium c++ O(N+M) O(M)
287 Find the Duplicated Number Array, Two Pointers, Binary Search, Bit Manipulation Medium c++ O(N) O(1)
200 Number of Islands Array, Depth-First Search, Breadth-First Search, Union Find, Matrix Medium c++ O(N^2) O(1)
384 Shuffle an Array Array, Math, Ramdomized Medium c++ O(N) O(N)
454 4Sum II Array, Hash Table Medium c++ O(N^2) O(N^2)
18 4Sum Array, Two Pointers, Sorting Medium c++ O(N^3) O(1)
300 Longest Increasing Subsequence Array, Binary Search, Dynamic Programming Medium c++ O(N^2) O(N)
11 Container With Most Water Array, Two Pointers, Greedy Medium c++ O(N) O(1)
73 Set Matrix Zeroes Array, Hash Table, Matrix Medium c++ O(NM+V) O(V)
380 Insert Delete GetRandom O(1) Array, Hash Table, Math, Design, Randomized Medium c++ O(1) O(N)
329 Longest Increasing Path in a Matrix Array, Dynamic Programming, Depth-First Search, Breadth-First Search, Graph, Topological Sort, Memoization, Matrix Hard c++ O(NM) O(NM)
240 Search a 2D Matrix II Array, Binary Search, Divide and Conquer, Matrix Medium c++ O(NLogM) O(1)
198 House Robber Array, Dynamic Programming Medium c++ O(N) O(1)
150 Evaluate Reverse Polish Notation Array, Math, Stack Medium c++ O(N) O(N)
88 Merge Sorted Array Array, Two Pointers, Sorting Easy c++ O(N) O(1)
54 Spiral Matrix Array, Matrix, Simulation Medium c++ O(NM) O(NM)
128 Longest Consecutive Sequence Array, Hash Table, Union Find Medium c++ O(N^2) O(N)
140 Word Break II Array, Hash Table, String, Dynamic Programming, Memoization Hard c++ O(NM) O(N)
56 Merge Intervals Array, Sorting Medium c++ O(NLogN) O(N)
139 Word Break Array, Hash Table, String, Dynamic Programming, Trie, Memoization Medium c++ O(NM) O(N)
239 Sliding Window Maximum Array, Queue, Sliding Window, Heap (Priority Queue), Monotonic Queue Medium c++ O(N) O(N)
162 Find Peak Element Array, Binary Search Medium c++ O(logN) O(1)
134 Gas Station Array, Greedy Medium c++ O(N) O(1)
34 Find First and Last Position of Element in Sorted Array Array, Binary Search Medium c++ O(logN) O(1)
79 Word Search Array, String, Backtracking, Matrix Medium c++ O(NMK) O(1)
334 Increasing Triplet Subsequence Array, Greedy Medium c++ O(N) O(1)
130 Surrounded Regions Array, Depth-First Search, Breadth-First Search, Union Find, Matrix Medium c++ O(NM) O(1)
55 Jump Game Array, Dynamic Programming, Greedy Medium c++ O(N) O(N)
179 Largest Number Array, String, Greedy, Sorting Medium c++ O(NlogN) O(N)
152 Maximum Product Subarray Array, Dynamic Programming Medium c++ O(N) O(N)
324 Wiggle Sort II Array, Divide and Conquer, Sorting, Quickselect Medium c++ O(NlogN) O(N)
204 Count Primes Array, Math, Enumeration, Number Theory Medium c++ O(NlogN) O(N)
149 Max Points on a Line Array, Hash Table, Math, Geometry Hard c++ O(N^2) O(N)
208 Implement Trie (Prefix Tree) Hash Table, String, Design, Trie Medium c++ O(N) O(N)
212 Word Search II Array, String, Backtracking, Trie, Matrix Hard c++ O(NMK) O(K)
41 Find Missing Postive Array, Hash Table Hard c++ O(N) O(1)
146 LRU Cache Hash Table, Linked List, Design, Doubly-Linked List Medium c++ O(1) O(N)
91 Decode Ways String, Dynamic Programming Medium c++ O(N) O(N)
5 Longest Palindromic Substring String, Dynamic Programming Medium c++ O(N^2) O(N)
22 Generate Parentheses String, Dynamic Programming, Backtracking Medium c++ O(2^N) O(N)
2824 Count Pairs Whose Sum is Less than Target Array, Two Pointers, Binary Search, Sorting Easy c++ O(NlogN) O(1)
475 Heaters Array, Two Pointers, Binary Search, Sorting Medium c++ O(NlogM) O(1)
1343 Number of Sub-arrays of Size K and Average Greater than or Equal to Threshold Array, Sliding Window Medium c++ O(N) O(1)
1347 Minimum Number of Steps to Make Two Strings Anagram Hash Table, String, Counting Medium c++ O(N) O(1)
894 All Possible Full Binary Trees Dynamic Programming, Tree, Recursion, Memoization, Binary Tree Medium c++ O(N) O(N)
1641 Count Sorted Vowel Strings Math, Dynamic Programming, Combinatorics Medium c++ O(N) O(1)
242 Valid Anagram Hash Table, String, Sorting Easy c++ O(N) O(N)
36 Valid Sudoku Array, Hash Table, Matrix Medium c++ O(1) O(1)
20 Valid Parentheses String, Stack Easy c++ O(N) O(N)
155 Min Stack Stack, Design Medium c++ O(1) O(N)
739 Daily Temperatures Array, Stack, Monotonic Stack Medium c++ O(N) O(N)
853 Car Fleet Array, Stack, Sorting, Monotonic Stack Medium c++ O(NlogN) O(N)
496 Next Greater Element I Array, Hash Table, Stack, Monotonic Stack Medium c++ O(N+M) O(M)
907 Sum of Subarray Minimums Array, Dynamic Programming, Stack, Monotonic Stack Medium c++ O(N) O(N)
84 Largest Rectangle in Histogram Array, Stack, Monotonic Stack Hard c++ O(N) O(N)
167 Two Sum II - Input Array Is Sorted Array, Two Pointers, Binary Search Medium c++ O(N) O(1)
42 Trapping Rain Water Array, Two Pointers, Dynamic Programming, Stack, Monotonic Stack Hard c++ O(N) O(N)
74 Search a 2D Matrix Array, Binary Search, Matrix Medium c++ O(log(N*M)) O(1)
874 Koko Eating Bananas Array, Binary Search Medium c++ O(Nlog(V)) O(1)
981 Time Based Key-Value Store Hash Table, String, Binary Search, Design Medium c++ O(log(N)) O(N)
4 Median of Two Sorted Arrays Array, Binary Search, Divide and Conquer Hard c++ O(log(NM)) O(1)
1588 Sum of All Odd Length Subarrays Array, Math, Prefix Sum Easy c++ O(N) O(1)
2384 Largest Palindromic Number Hash Table, String, Greedy Medium c++ O(N) O(N)
464 Can I Win Math, Dynamic Programming, Bit Manipulation, Memoization, Game Theory, Bitmask Medium c++ O(2^N) O(10^N)
424 Longest Repeating Character Replacement Hash Table, String, Sliding Window Medium c++ O(N) O(1)
567 Permutation in String Hash Table, Two Pointers, String, Sliding Window Medium c++ O(N) O(1)
76 Minimum Window Substring Hash Table, String, Sliding Window Hard c++ O(N) O(1)
21 Merge Two Sorted Lists Linked List, Recursion Easy c++ O(N) O(1)
143 Reorder List Linked List, Two Pointers, Stack, Recursion Medium c++ O(N) O(N)
138 Copy List with Random Pointer Hash Table, Linked List Medium c++ O(N) O(N)
142 Linked List Cycle II Hash Table, Linked List, Two Pointers Medium c++ O(N) O(1)
23 Merge k Sorted Lists Linked List, Divide and Conquer, Heap (Priority Queue), Merge Sort Hard c++ O(NlogK) O(K)
25 Reverse Nodes in k-Group Linked List, Recursion Hard c++ O(N) O(1)
763 Partition Labels Hash Table, Two Pointers, String, Greedy Medium c++ O(N) O(N)
226 Invert Binary Tree Tree, Depth-First Search, Breadth-First Search, Binary Tree Easy c++ O(N) O(1)
543 Diameter of Binary Tree Tree, Depth-First Search, Binary Tree Easy c++ O(N) O(1)
572 Subtree of Another Tree Tree, Depth-First Search, String Matching, Binary Tree, Hash Function Easy c++ O(N) O(1)
102 Binary Tree Level Order Traversal Tree, Breadth-First Search, Binary Tree Medium c++ O(N) O(2^D)
235 Lowest Common Ancestor of a Binary Search Tree Tree, Depth-First Search, Binary Search Tree, Binary Tree Medium c++ O(N) O(1)
199 Binary Tree Right Side View Tree, Depth-First Search, Breadth-First Search, Binary Tree Medium c++ O(N) O(logN)
1448 Count Good Nodes in Binary Tree Tree, Depth-First Search, Breadth-First Search, Binary Tree Medium c++ O(N) O(1)
98 Validate Binary Search Tree Tree, Depth-First Search, Breadth-First Search, Binary Tree Medium c++ O(N) O(1)
1535 Find the Winner of an Array Game Array, Simulation Medium c++ O(N) O(N)
230 Kth Smallest Element in a BST Tree, Depth-First Search, Binary Search Tree, Binary Tree Medium c++ O(K) O(1)
124 Binary Tree Maximum Path Sum Dynamic Programming, Tree, Depth-First Search, Binary Tree Hard c++ O(N) O(1)
297 Serialize and Deserialize Binary Tree String, Tree, Depth-First Search, Breadth-First Search, Design, Binary Tree Hard c++ O(N) O(N)
211 Design Add and Search Words Data Structure String, Depth-First Search, Design, Trie Medium c++ O(N) O(N)
703 Kth Largest Element in a Stream Tree, Design, Binary Search Tree, Heap (Priority Queue), Binary Tree, Data Stream Easy c++ O(N) O(K)
1046 Last Stone Weight Array, Heap (Priority Queue) Easy c++ O(NlogN) O(N)
973 K Closest Points to Origin Array, Math, Divide and Conquer, Geometry, Sorting, Heap (Priority Queue), Quickselect Medium c++ O(NlogK) O(K)
621 Task Scheduler Array, Hash Table, Greedy, Sorting, Heap (Priority Queue), Counting Medium c++ O(N) O(N)
355 Design Twitter Hash Table, Linked List, Design, Heap (Priority Queue) Medium c++ O(K*NlogN) O(N)
904 Fruit Into Baskets Array, Hash Table, Sliding Window Medium c++ O(N) O(1)
295 Find Median from Data Stream Two Pointers, Design, Sorting, Heap (Priority Queue), Data Stream Hard c++ O(logN) O(N)
39 Combination Sum Array, Backtracking Medium c++ O(NlogN+K/min) O(K/min)
40 Combination Sum II Array, Backtracking Medium c++ O(NlogN+M*2^N) O(N)
131 Palindrome Partitioning String, Dynamic Programming, Backtracking Medium c++ O(N^2) O(N^2)
17 Letter Combinations of a Phone Number Hash Table, String, Backtracking Medium c++ O(N) O(N)
746 Min Cost Climbing Stairs Array, Dynamic Programming Easy c++ O(N) O(N)
51 N-Queens Array, Backtracking Hard c++ O(N!) O(N)
3112 Minimum Time to Visit Disappearing Nodes Graph Medium c++ O(N^V) O(N)
3110 Score of a String String Easy c++ O(N) O(1)
3111 Minimum Rectangles to Cover Points Array Medium c++ O(NlogN) O(N)
647 Palindromic Substrings Two Pointers, String, Dynamic Programming Medium c++ O(N^2) O(1)
416 Partition Equal Subset Sum Array, Dynamic Programming Medium c++ O(N^2) O(N)
695 Max Area of Island Array, Depth-First Search, Breadth-First Search, Union Find, Matrix Medium c++ O(NMK) O(1)
133 Clone Graph Hash Table, Depth-First Search, Breadth-First Search, Graph Medium c++ O(NV) O(N)
994 Rotting Oranges Array, Breadth-First Search, Matrix Medium c++ O(NM) O(NM)
417 Pacific Atlantic Water Flow Array, Depth-First Search, Breadth-First Search, Matrix Medium c++ O(NM) O(NM)
207 Course Schedule Depth-First Search, Breadth-First Search, Graph, Topological Sort Medium c++ O(N+E) O(N)
1391 Check if There is a Valid Path in a Grid Array, Depth-First Search, Breadth-First Search, Union Find, Matrix Medium c++ O(N*M) O(1)
2830 Maximize the Profit as the Salesman Array, Hash Table, Binary Search, Dynamic Programming, Sorting Medium c++ O(MlogM) O(M)
210 Course Schedule II Depth-First, Search, Breadth-First Search, Graph, Topological Sort Medium c++ O(N+E) O(N*E)
684 Redundant Connection Depth-First Search, Breadth-First Search, Union Find, Graph Medium c++ O(N) O(N)
127 Word Ladder Hash Table, String, Breadth-First Search Hard c++ O(WNlogN) O(N)
1143 Longest Common Subsequence String, Dynamic Programming Medium c++ O(NM) O(NM)
435 Non-overlapping Intervals Array, Dynamic Programming, Greedy, Sorting Medium c++ O(NlogN) O(1)
57 Insert Interval Array Medium c++ O(N) O(N)
309 Best Time to Buy and Sell Stock with Cooldown Array, Dynamic Programming Medium c++ O(N) O(N)
97 Interleaving String String, Dynamic Programming Medium c++ O(N*M) O(N*M)
115 Distinct Subsequences String, Dynamic Programming Hard c++ O(N*M) O(N*M)
72 Edit Distance String, Dynamic Programming Hard c++ O(N*M) O(N*M)
1705 Maximum Number of Eaten Apples Array, Greedy, Heap (Priority Queue) Medium c++ O(NlogN) O(N)
1367 Linked List in Binary Tree Linked List, Tree, Depth-First Search, Breadth-First Search, Binary Tree Medium c++ O(N+M) O(1)
312 Burst Balloons Array, Dynamic Programming Hard c++ O(N^2) O(N^2)
1851 Minimum Interval to Include Each Query Array, Binary Search, Line Sweep, Sorting, Heap (Priority Queue) Hard c++ O((N+M)logN) O(N+M)
338 Counting Bits Dynamic Programming
Bit Manipulation Easy c++ O(N) O(N)
371 Sum of Two Integers Math, Bit Manipulation Medium c++ O(1) O(1)
7 Reverse Integer Math Medium c++ O(N) O(1)
252 Meeting Rooms Intervals Easy c++ O(N) O(1)
253 Meeting Rooms II Intervals Easy c++ O(N^2) O(N)
53 Maximum Subarray Array, Divide and Conquer, Dynamic Programming Medium c++ O(N) O(1)
45 Jump Game II Array, Dynamic Programming, Greedy Medium c++ O(N) O(1)
846 Hand of Straights Array, Hash Table, Greedy, Sorting Medium c++ O(NlogN) O(N)
1899 Merge Triplets to Form Target Triplet Array, Greedy Medium c++ O(N) O(N)
678 Valid Parenthesis String String, Dynamic Programming, Stack, Greedy Medium c++ O(N) O(1)
1509 Minimum Difference Between Largest and Smallest Value in Three Moves Array, Greedy, Sorting Medium c++ O(1) O(1)
1525 Number of Good Ways to Split a String Hash Table, String, Dynamic Programming, Bit Manipulation Medium c++ O(N) O(N)
3114 Latest Time You Can Obtain After Replacing Characters String, Enumeration Easy c++ O(1) O(1)
1200 Minimum Absolute Difference Array, Sorting Easy c++ O(NlogN) O(N)
1007 Minimum Domino Rotations For Equal Row Array, Greedy Medium c++ O(N) O(1)
1888 Minimum Number of Flips to Make the Binary String Alternating String, Dynamic Programming, Greedy, Sliding Window Medium c++ O(N) O(1)
274 H-Index Array, Sorting, Counting Sort Medium c++ O(N) O(1)
1584 Min Cost to Connect All Points Array, Union Find, Graph, Minimum Spanning Tree Medium c++ O(N^2) O(N)
743 Network Delay Time Depth-First Search, Breadth-First Search, Graph, Heap (Priority Queue), Shortest Path Medium c++ O(N^2) O(N^2)
1825 Finding MK Average Design, Queue, Heap (Priority Queue), Data Stream, Ordered Set Hard c++ O(logN) O(1)
874 Walking Robot Simulation Array, Hash Table, Simulation Medium c++ O(N) O(N)
2547 Minimum Cost to Split an Array Array, Hash Table, Dynamic Programming, Counting Hard c++ O(N^2) O(N)
2982 Find Longest Special Substring That Occurs Thrice II Hash Table, String, Binary Search, Sliding Window, Counting Medium c++ O(N) O(N)
2958 Length of Longest Subarray With at Most K Frequency Array, Hash Table, Sliding Window Medium c++ O(N) O(N)
359 Logger Rate Limiter Hash Table, Design, Data Stream Easy c++ O(1) O(N)
2402 Meeting Rooms III Array, Hash Table, Sorting, Heap (Priority Queue), Simulation Hard c++ O(NlogN) O(N)
1110 Delete Nodes And Return Forest Array, Hash Table, Tree, Depth-First Search, Binary Tree Medium c++ O(V) O(V)
715 Range Module Design, Segment Tree, Ordered Set Hard c++ O(NlogN) O(NlogN)
939 Minimum Area Rectangle Array, Hash Table, Math, Geometry, Sorting Medium c++ O(N^2) O(1)
1101 The Earliest Moment When Everyone Become Friends Array, Union Find, Sorting Medium c++ O(N^2) O(N)
975 Odd Even Jump Array, Dynamic Programming, Stack, Monotonic Stack, Ordered Set Hard c++ O(NlogN) O(N)
2863 Maximum Length of Semi-Decreasing Subarrays Array, Hash Table, Sorting Medium c++ O(N) O(N)
2013 Detect Squares Array, Hash Table, Design, Counting Medium c++ O(N) O(N)
2458 Height of Binary Tree After Subtree Removal Queries Array, Tree, Depth-First Search, Breadth-First Search, Binary Tree Hard c++ O(V+N) O(V)
85 Maximal Rectangle Array, Dynamic Programming, Stack, Matrix, Monotonic Stack Hard c++ O(N*M) O(N)
554 Brick Wall Array, Hash Table Medium c++ O(N*M) O(N)
2184 Number of Ways to Build Sturdy Brick Wall Array, Dynamic Programming, Bit Manipulation, Bitmask Medium c++ O(2W*H) O(H*2W)
963 Minimum Area Rectangle II Array, Math, Geometry Medium c++ O(N^2) O(N^2)
2290 Minimum Obstacle Removal to Reach Corner Array, Breadth-First Search, Graph, Heap (Priority Queue), Matrix, Shortest Path Hard c++ O(N^2) O(N^2)
655 Print Binary Tree Tree, Depth-First Search, Breadth-First Search, Binary Tree Medium c++ O(V) O(V)
2316 Count Unreachable Pairs of Nodes in an Undirected Graph Depth-First Search, Breadth-First, Search, Union Find, Graph Medium c++ O(N^2) O(N)
778 Swim in Rising Water Array, Binary Search, Depth-First Search, Breadth-First Search, Union Find, Heap (Priority Queue), Matrix Hard c++ O(N^2) O(N^2)
1136 Parallel Courses Graph, Topological Sort Medium c++ O(V+E) O(V+E)
2115 Find All Possible Recipes from Given Supplies Array, Hash Table, String, Graph, Topological Sort Medium c++ O(NM+K) O(NM+K)
833 Find And Replace in String Array, String, Sorting Medium c++ O(N+M) O(M+K)
269 Alien Dictionary Array, String, Depth-First Search, Breadth-First Search, Graph, Topological Sort Hard c++ O(NW+E) O(N+E)
2122 Recover the Original Array Array, Hash Table, Sorting, Enumeration Hard c++ O(N^2) O(N)
2973 Find Number of Coins to Place in Tree Nodes Dynamic Programming, Tree, Depth-First Search, Sorting, Heap (Priority Queue) Medium c++ O(E) O(N+E)
365 Water and Jug Problem Dynamic Programming, Tree, Depth-First Search, Sorting, Heap (Priority Queue) Medium c++ O(E) O(N+E)
1820 Maximum Number of Accepted Invitations Array, Backtracking, Matrix Medium c++ O(N*M) O(N)
1756 Design Most Recently Used Queue Array, Hash Table, Stack, Design, Binary Indexed Tree, Ordered Set Medium c++ O(N) O(N)
1940 Longest Common Subsequence Between Sorted Arrays Array, Hash Table, Counting Medium c++ O(MNlogM) O(N)
2486 Append Characters to String to Make Subsequence Two Pointers, String, Greedy Medium c++ O(N) O(1)
1005 Maximize Sum Of Array After K Negations Array, Greedy, Sorting Easy c++ O(NlogN) O(1)
409 Longest Palindrome Hash Table, String, Greedy Easy c++ O(N) O(N)
1605 Find Valid Matrix Given Row and Column Sums Array, Greedy, Matrix Medium c++ O(NM) O(NM)
787 Cheapest Flights Within K Stops Dynamic Programming, Depth-First Search, Breadth-First Search, Graph, Heap (Priority Queue), Shortest Path Medium c++ O(N^2*K) O(N^2)
2191 Sort the Jumbled Numbers Array, Sorting Medium c++ O(N*(logN + W)) O(N)
1636 Sort Array by Increasing Frequency Array, Hash Table, Sorting Easy c++ O(N) O(N)
1137 N-th Tribonacci Number Math, Dynamic Programming, Memoization Easy c++ O(N) O(N)
740 Delete and Earn Array, Hash Table, Dynamic Programming Medium c++ O(NlogN) O(N)
1929 Concatenation of Array Array, Simulation Easy c++ O(N) O(N)
1299 Replace Elements with Greatest Element on Right Side Array Easy c++ O(N) O(1)
58 Length of Last Word String Easy c++ O(N) O(1)
929 Unique Email Address Array, Hash Table, String Easy c++ O(N) O(N)
609 Can Place Flowers Array, Greedy Easy c++ O(N) O(1)
303 Range Sum Query - Immutable Array, Design, Prefix Sum Easy c++ O(N) O(1)
1189 Maximum Number of Balloons Hash Table, String, Counting Easy c++ O(N) O(1)
290 Word Pattern Hash Table, String Easy c++ O(N+M) O(N+M)
706 Design HashMap Array, Hash Table, Linked List, Design, Hash Function Easy c++ O(1) O(N)
705 Design HashSet Array, Hash Table, Linked List, Design, Hash Function Easy c++ O(1) O(N)
896 Monotonic Array Array Easy c++ O(N) O(1)
1512 Number of Good Pairs Array, Hash Table, Math, Counting Easy c++ O(N) O(N)
119 Pascal's Triangle II Array, Dynamic Programming Easy c++ O(N^2) O(N)
2264 Largest 3-Same-Digit Number in String String Easy [c++](/c++/2264
) O(N) O(N)
1436 Destination City Array, Hash Table, String Easy c++ O(N) O(N)
1913 Maximum Product Difference Between Two Pairs Array, Sorting Easy c++ O(N) O(1)
1422 Maximum Score After Splitting a String String, Prefix Sum Easy c++ O(N) O(1)
1496 Path Crossing Hash Table, String Easy c++ O(N) O(N)
1758 Minimum Changes To Make Alternating Binary String String Easy c++ O(N) O(1)
1897 Redistribute Characters to Make All Strings Equal Hash Table, String, Counting Easy c++ O(W*N) O(1)
1624 Largest Substring Between Two Equal Characters Hash Table, String Easy c++ O(N) O(1)
1700 Number of Students Unable to Eat Lunch Array, Stack, Queue, Simulation Easy c++ O(N) O(1)
349 Intersection of Two Arrays Array, Hash Table, Two Pointers, Binary Search, Sorting Easy c++ O(NlogN+MlogM) O(K)
387 First Unique Character in a String Hash Table, String, Queue, Counting Easy c++ O(N) O(1)
387 First Unique Character in a String Hash Table, String, Queue, Counting Easy c++ O(N) O(1)
645 Set Mismatch Array, Hash Table, Bit Manipulation, Sorting Easy c++ O(N) O(N)
2073 Time Needed to Buy Tickets Array, Queue, Simulation Easy c++ O(N) O(1)
1608 Special Array With X Elements Greater Than or Equal X Array, Binary Search, Sorting Easy c++ O(NlogN) O(1)
535 Encode and Decode TinyURL Hash Table, String, Design, Hash Function Medium c++ O(N) O(N)
560 Subarray Sum Equals K Array, Hash Table, Prefix Sum Medium c++ O(N) O(N)
1930 Unique Length-3 Palindromic Subsequences Hash Table, String, Bit Manipulation, Prefix Sum Medium c++ O(N^2) O(N)
1963 Minimum Number of Swaps to Make the String Balanced Two Pointers, String, Stack, Greedy Medium c++ O(N) O(1)
2001 Number of Pairs of Interchangeable Rectangles Array, Hash Table, Math, Counting, Number Theory Medium c++ O(N) O(N)
2002 Maximum Product of the Length of Two Palindromic Subsequences String, Dynamic Programming, Backtracking, Bit Manipulation, Bitmask Medium c++ O(N^2) O(N)
2017 Grid Game Array, Matrix, Prefix Sum Medium c++ O(N) O(N)
438 Find All Anagrams in a String Hash Table, String, Sliding Window Medium c++ O(N+M) O(1)
28 Find the Index of the First Occurrence in a String Two Pointers, String, String Matching Easy c++ O(NM) O(1)
523 Continuous Subarray Sum Array, Hash Table, Math, Prefix Sum Medium c++ O(N) O(N)
838 Push Dominoes Two Pointers, String, Dynamic Programming Medium c++ O(N) O(N)
187 Repeated DNA Sequences Hash Table, String, Bit Manipulation, Sliding Window, Rolling Hash, Hash Function Medium c++ O(N) O(N)
1461 Check If a String Contains All Binary Codes of Size K Hash Table, String, Bit Manipulation, Rolling Hash, Hash Function Medium c++ O(N) O(N)
304 Range Sum Query 2D - Immutable Array, Design, Matrix, Prefix Sum Medium c++ O(1) O(N*M)
665 Non-decreasing Array Array Medium c++ O(N) O(1)
1822 Sign of the Product of an Array Array, Math Easy c++ O(N) O(1)
126 Word Ladder II Hash Table, String, Backtracking, Breadth-First Search Hard c++ O(N*K) O(N)
1603 Design Parking System Design, Simulation, Counting Easy c++ O(1) O(1)
2348 Number of Zero-Filled Subarrays Array, Math Medium c++ O(N) O(1)
933 Number of Recent Calls Design, Queue, Data Stream Easy c++ O(1) O(1)
362 Design Hit Counter Array, Binary Search, Design, Queue, Data Stream Medium c++ O(N) O(1)
649 Dota2 Senate String, Greedy, Queue Medium c++ O(N) O(N)
1396 Design Underground System Hash Table, String, Design Medium c++ O(1) O(N)
1768 Merge Strings Alternately Two Pointers, String Easy c++ O(N) O(N)
2483 Minimum Penalty for a Shop String, Prefix Sum Medium c++ O(N) O(1)
799 Champagne Tower Dynamic Programming Medium c++ O(N^2) O(N^2)