Skip to content

starFalll/LeetCode

Repository files navigation

LeetCode

LeetCode Solution

# Title Solution
1 Two Sum C++
2 Add Two Numbers C++
3 Longest Substring Without Repeating Characters C++
4 Median of Two Sorted Arrays C++
5 Longest Palindromic Substring C++
6 ZigZag Conversion C++
7 Letter Combinations of a Phone Number C++
8 String to Integer (atoi) C++
9 Palindrome Number C++
10 Regular Expression Matching C++
11 Container With Most Water C++
12 Integer to Roman C++
13 Roman to Integer C++
14 Longest Common Prefix C++
15 3Sum C++
16 3Sum Closest C++
17  Letter Combinations of a Phone Number C++
18 4Sum* C++
19 Remove Nth Node From End of List C++
20 Valid Parentheses C++
21 Merge Two Sorted Lists C++
22 Generate Parentheses C++
23 Merge k Sorted Lists C++
24 Swap Nodes in Pairs C++
25 Reverse Nodes in k-Group C++
26 Remove Duplicates from Sorted Array C++
27 Remove Element C++
28 Implement strStr() C++
29 Divide Two Integers C++
30 Substring with Concatenation of All Words C++
31 Next Permutation C++
32 Longest Valid Parentheses C++
33 Search in Rotated Sorted Array C++
34 Find First and Last Position of Element in Sorted Array C++
35 Search Insert Position C++
36 Valid Sudoku C++
37 Sudoku Solver C++
38 Count and Say C++
39 Combination Sum C++
40 Combination Sum II C++
41 First Missing Positive C++
42 Trapping Rain Water C++
43 Multiply Strings C++
44 Wildcard Matching C++
45 Jump Game II C++
46 Permutations C++
47 Permutations II C++
48 Rotate Image C++
49 Group Anagrams C++
50 Pow(x, n) C++
51 N-Queens C++
52 N-Queens II C++
53 Maximum Subarray C++
54 Spiral Matrix C++
55 Jump Game C++
56  Merge Intervals C++
57 Insert Interval C++
58 Length of Last Word C++
59 Spiral Matrix II C++
60 Permutation Sequence C++
61 Rotate List C++
62 Unique Paths C++
63 Unique Paths II C++
64 Minimum Path Sum C++
65 Valid Number C++
66 Plus One C++
67 Add Binary C++
68 Text Justification C++
69 Sqrt(x) C++
70 Climbing Stairs C++
71 Simplify Path C++
72  Edit Distance C++
73 Set Matrix Zeroes C++
74 Search a 2D Matrix C++
75 Sort Colors C++
76 Minimum Window Substring C++
77 Combinations C++
78 Subsets C++
79 Word Search C++
80 Remove Duplicates from Sorted Array II C++
81 Search in Rotated Sorted Array II C++
82 Remove Duplicates from Sorted List II C++
83 Remove Duplicates from Sorted List C++
84 Largest Rectangle in Histogram C++
86 Partition List C++
88 Merge Sorted Array C++
89 Gray Code C++
90 Subsets II C++
91 Decode Ways C++
92 Reverse Linked List II C++
93 Restore IP Addresses C++
94 Binary Tree Inorder Traversal C++
95 Unique Binary Search Trees II C++
96 Unique Binary Search Trees C++
97 Interleaving String C++
98 Validate Binary Search Tree C++
99 Recover Binary Search Tree C++
100 Same Tree C++
101 Symmetric Tree C++
102 Binary Tree Level Order Traversal C++
103 Binary Tree Zigzag Level Order Traversal C++
104 Maximum Depth of Binary Tree C++
105 Construct Binary Tree from Preorder and Inorder Traversa C++
106 Construct Binary Tree from Inorder and Postorder Travers C++
107 Binary Tree Level Order Traversal II C++
108 Convert Sorted Array to Binary Search Tree C++
109 Convert Sorted List to Binary Search Tree C++
110 Balanced Binary Tree C++
111 Minimum Depth of Binary Tree C++
112 Path Sum C++
113 Path Sum II C++
114 Flatten Binary Tree to Linked List C++
115 Distinct Subsequences C++
116 Populating Next Right Pointers in Each Node C++
117 Populating Next Right Pointers in Each Node II C++
118 Pascal's Triangle C++
119 Pascal's Triangle II C++
120 Triangle C++
121 Best Time to Buy and Sell Stock C++
122 Best Time to Buy and Sell Stock II C++
123 Best Time to Buy and Sell Stock III C++
124 Binary Tree Maximum Path Sum C++
125 Valid Palindrome C++
126 Word Ladder II C++
127 Word Ladder C++
128 Longest Consecutive Sequence C++
129 Sum Root to Leaf Numbers C++
130 Surrounded Regions C++
131 Palindrome Partitioning C++
132 Palindrome Partitioning II C++
133 Clone Graph C++
134 Gas Station C++
135 Candy C++
136 Single Number C++
137 Single Number II C++
138 Copy List with Random Pointer C++
139 Word Break C++
140 Word Break II C++
141 Linked List Cycle C++
142 Linked List Cycle II C++
143 Reorder List C++
144 Binary Tree Preorder Traversal C++
145 Binary Tree Postorder Traversal C++
146 LRU Cache C++
147 Insertion Sort List C++
148 Sort List C++
149 Max Points on a Liney C++
150 Evaluate Reverse Polish Notation C++
151 Reverse Words in a String C++
152 Maximum Product Subarray C++
153 Find Minimum in Rotated Sorted Array C++
154 Find Minimum in Rotated Sorted Array II C++
155 Min Stack C++
156 Binary Tree Upside Down C++
157 Read N Characters Given Read4 C++
158 Read N Characters Given read4 II - Call Multiple Times C++
159 Longest Substring with At Most Two Distinct Characters C++
160 Intersection of Two Linked Lists C++
161 One Edit Distance C++
162 Find Peak Element C++
163 Missing Ranges C++
164 Maximum Gap C++
165 Compare Version Numbers C++
166 Fraction to Recurring Decimal C++
167 Two Sum II - Input array is sorted C++
168 Excel Sheet Column Title C++
169 Majority Element C++
170 Two Sum III - Data structure design C++
171 Excel Sheet Column Number C++
172 Factorial Trailing Zeroes C++
173 Binary Search Tree Iterator C++
174 Dungeon Game C++
179 Largest Number C++
186 Reverse Words in a String II C++
187 Repeated DNA Sequences C++
188 Best Time to Buy and Sell Stock IV C++
189 Rotate Array C++
190 Reverse Bits C++
191 Number of 1 Bits C++
198 House Robber C++
199 Binary Tree Right Side View C++
200 Number of Islands C++
201 Bitwise AND of Numbers Range C++
202 Happy Number C++
203 Remove Linked List Elements C++
204 Count Primes C++
205 Isomorphic Strings C++
206 Reverse Linked List C++
207 Course Schedule C++
208 Implement Trie (Prefix Tree) C++
209 Minimum Size Subarray Sum C++
210 Course Schedule II C++
211 Add and Search Word - Data structure design C++
212 Word Search II C++
213 House Robber II C++
214 Shortest Palindrome C++
215 Kth Largest Element in an Array C++
217 Contains Duplicate C++
218 The Skyline Problem C++
221 Maximal Square C++
222 Count Complete Tree Nodes C++
224 Basic Calculator C++
226 Invert Binary Tree C++
227 Basic Calculator II C++
230 Kth Smallest Element in a BST C++
234 Palindrome Linked List C++
235 Lowest Common Ancestor of a Binary Search Tree C++
236 Lowest Common Ancestor of a Binary Tree C++
237 Delete Node in a Linked List C++
238 Product of Array Except Self C++
239 Sliding Window Maximum C++
240 Search a 2D Matrix II C++
242 Valid Anagram C++
251 Flatten 2D Vector C++
253 Meeting Rooms II C++
256 Paint House C++
259 3Sum Smaller C++
260 Single Number III C++
264 Ugly Number II C++
268 Missing Number C++
269 Alien Dictionary C++
276 Paint Fence C++
277 Find the Celebrity C++
279 Perfect Squares C++
282 Expression Add Operators C++
283 Move Zeroes C++
284 Peeking Iterator C++
285 Inorder Successor in BST C++
287 Find the Duplicate Number C++
289 Game of Life C++
291 Word Pattern II C++
295 Find Median from Data Stream C++
297 Serialize and Deserialize Binary Tree C++
300 Longest Increasing Subsequence C++
301 Remove Invalid Parentheses C++
305 Number of Islands II C++
308 Range Sum Query 2D-Mutable C++
309 Best Time to Buy and Sell Stock with Cooldown C++
314 Binary Tree Vertical Order Traversal C++
315 Count of Smaller Numbers After Self C++
322 Coin Change C++
324 Wiggle Sort II C++
326 Power of Three C++
328 Odd Even Linked List C++
329 Longest Increasing Path in a Matrix C++
332 Reconstruct Itinerary C++
334 Increasing Triplet Subsequence C++
337 House Robber III C++
338 Counting Bits C++
340 Longest Substring with At Most K Distinct Characters C++
341 Flatten Nested List Iterator C++
343 Integer Break C++
344 Reverse String C++
347 Top K Frequent Elements C++
348 Design Tic-Tac-Toe C++
350 Intersection of Two Arrays II C++
354 Russian Doll Envelopes C++
355 Design Twitter C++
365 How Many Numbers Are Smaller Than the Current Number C++
365 Water and Jug Problem C++
366 Find Leaves of Binary Tree C++
371 Sum of Two Integers C++
376 Wiggle Subsequence C++
377 Combination Sum IV C++
378 Kth Smallest Element in a Sorted Matrix C++
380 Insert Delete GetRandom O(1) C++
381 Insert Delete GetRandom O(1) - Duplicates allowed C++
384 Shuffle an Array C++
387 First Unique Character in a String C++
392 Is Subsequence C++
394 Decode String C++
395 Longest Substring with At Least K Repeating Characters C++
398 Random Pick Index C++
399 Evaluate Division C++
406 Queue Reconstruction by Height C++
407 Trapping Rain Water II C++
414 Third Maximum Number C++
415 Add Strings C++
416 Partition Equal Subset Sum C++
417 Pacific Atlantic Water Flow C++
426 Convert Binary Search Tree to Sorted Doubly Linked List C++
438 Find All Anagrams in a String C++
440 K-th Smallest in Lexicographical Order C++
443 String Compression C++
444 Sequence Reconstruction C++
445 Add Two Numbers II C++
450 Delete Node in a BST C++
451 Sort Characters By Frequency C++
452 Minimum Number of Arrows to Burst Balloons C++
454 4Sum II C++
455 Assign Cookies C++
460 LFU Cache C++
465 Optimal Account Balancing C++
472 Concatenated Words C++
474 Ones and Zeroes C++
489 Robot Room Cleaner C++
491 Non-decreasing Subsequences C++
493 Reverse Pairs C++
494 Target Sum C++
496 Next Greater Element I C++
498 Diagonal Traverse C++
503 Next Greater Element II C++
505 The Maze II C++
509 Fibonacci Number C++
515 Find Largest Value in Each Tree Row C++
516 Longest Palindromic Subsequence C++
518 Coin Change II C++
523 Continuous Subarray Sum C++
528 Random Pick with Weight C++
532 K-diff Pairs in an Array C++
539 Minimum Time Difference C++
540 Single Element in a Sorted Array C++
542 01 Matrix C++
543 Diameter of Binary Tree C++
547 Friend Circles C++
556 Next Greater Element III C++
560 Subarray Sum Equals K C++
565 Array Nesting C++
567 Permutation in String C++
568 Maximum Vacation Days C++
583 Delete Operation for Two Strings C++
588 Design In-Memory File System C++
606 Construct String from Binary Tree C++
617 Merge Two Binary Trees C++
622 Design Circular Queue C++
642 Design Search Autocomplete System C++
647 Palindromic Substrings C++
654 Maximum Binary Tree C++
658 Find K Closest Elements C++
659 Max Area of Island C++
674 Longest Continuous Increasing Subsequence C++
679 24 Game C++
680 Valid Palindrome II C++
684 Redundant Connection C++
688 Knight Probability in Chessboard C++
700 Search in a Binary Search Tree C++
704 Binary Search C++
713 Subarray Product Less Than K C++
714 Best Time to Buy and Sell Stock with Transaction Fee C++
715 Range Module C++
718 Maximum Length of Repeated Subarray C++
719 Find K-th Smallest Pair Distance C++
725 Split Linked List in Parts C++
735 Asteroid Collision C++
739 Daily Temperatures C++
743 Network Delay Time C++
745 Prefix and Suffix Search C++
746 Min Cost Climbing Stairs C++
759 Employee Free Time C++
764 Largest Plus Sign C++
767 Reorganize String C++
768 Max Chunks To Make Sorted II C++
772 Basic Calculator III C++
773 Sliding Puzzle C++
785 Is Graph Bipartite? C++
787 Cheapest Flights Within K Stops C++
802 Find Eventual Safe States C++
815 Bus Routes C++
818 Race Car C++
823 Binary Trees With Factors C++
827 Making A Large Island C++
834 Sum of Distances in Tree C++
843 Guess the Word C++
847 Shortest Path Visiting All Nodes C++
853 Car Fleet C++
860 Lemonade Change C++
863 All Nodes Distance K in Binary Tree C++
864 Shortest Path to Get All Keys C++
885 Spiral Matrix III C++
900 RLE Iterator C++
909 Snakes and Ladders C++
919 Complete Binary Tree Inserter C++
920 Number of Music Playlists C++
921 Minimum Add to Make Parentheses Valid C++
924 Minimize Malware Spread C++
928 Minimize Malware Spread II C++
938 Range Sum of BST C++
939 Minimum Area Rectangle C++
941 Valid Mountain Array C++
946 Validate Stack Sequences C++
968 Binary Tree Cameras C++
973 K Closest Points to Origin C++
975 Odd Even Jump C++
980 Unique Paths III C++
987 Vertical Order Traversal of a Binary Tree C++
992 Subarrays with K Different Integers C++
993 Cousins in Binary Tree C++
994 Rotting Oranges C++
996 Number of Squareful Arrays C++
1005 Maximize Sum Of Array After K Negations C++
1011 Capacity To Ship Packages Within D Days C++
1035 Uncrossed Lines C++
1036 Escape a Large Maze C++
1043 Partition Array for Maximum Sum C++
1057 Campus Bikes C++
1062 Longest Repeating Substring C++
1066 Campus Bikes II C++
1074 Number of Submatrices That Sum to Target C++
1088 Confusing Number II C++
1095 Find in Mountain Array C++
1096 Brace Expansion II C++
1101 The Earliest Moment When Everyone Become Friends C++
1106 Parsing A Boolean Expression C++
1110 Delete Nodes And Return Forest C++
1114 Print in Order C++
1115 Print FooBar Alternately C++
1116 Print Zero Even Odd C++
1117 Building H2O C++
1136 Parallel Courses C++
1143 Longest Common Subsequence C++
1153 String Transforms Into Another String C++
1155 Number of Dice Rolls With Target Sum C++
1165 Single-Row Keyboard C++
1167 Minimum Cost to Connect Sticks C++
1188 Design Bounded Blocking Queue C++
1195 Fizz Buzz Multithreaded C++
1197 Minimum Knight Moves C++
1203 Sort Items by Groups Respecting Dependencies C++
1207 Unique Number of Occurrences C++
1209 Remove All Adjacent Duplicates in String II C++
1226 The Dining Philosophers C++
1229 Meeting Scheduler C++
1235 Maximum Profit in Job Scheduling C++
1242 Web Crawler Multithreaded C++
1245 Tree Diameter C++
1257 Smallest Common Region C++
1268 Search Suggestions System C++
1272 Remove Interval C++
1279 Traffic Light Controlled Intersection C++
1282 Group the People Given the Group Size They Belong To C++
1293 Shortest Path in a Grid with Obstacles Elimination C++
1310 XOR Queries of a Subarray C++
1319 Number of Operations to Make Network Connected C++
1326 Minimum Number of Taps to Open to Water a Garden C++
1335 Minimum Difficulty of a Job Schedule C++
1344 Angle Between Hands of a Clock C++
1345 Jump Game IV C++
1352 Product of the Last K Numbers C++
1358 Number of Substrings Containing All Three Characters C++
1359 Count All Valid Pickup and Delivery Options C++
1359 Count All Valid Pickup and Delivery Options C++
1371 Find the Longest Substring Containing Vowels in Even Counts C++
1382 Balance a Binary Search Tree C++
1405 Longest Happy String C++
1428 Leftmost Column with at Least a One C++
1442 Count Triplets That Can Form Two Arrays of Equal XOR C++
1457 Pseudo-Palindromic Paths in a Binary Tree C++
1458 Max Dot Product of Two Subsequences C++
1460 Make Two Arrays Equal by Reversing Subarrays C++
1463 Cherry Pickup II C++
1494 Parallel Courses II C++
1497 Check If Array Pairs Are Divisible by k C++
1507 Reformat Date C++
1508 Range Sum of Sorted Subarray Sums C++
1509 Minimum Difference Between Largest and Smallest Value in Three Moves C++
1541 Minimum Insertions to Balance a Parentheses String C++
1552 Magnetic Force Between Two Balls C++
1573 Number of Ways to Split a String C++
1578 Minimum Time to Make Rope Colorful C++
1584 Min Cost to Connect All Points C++
1601 Maximum Number of Achievable Transfer Requests C++
1609 Even Odd Tree C++
1610 Maximum Number of Visible Points C++
1631 Path With Minimum Effort C++
1634 Add Two Polynomials Represented as Linked Lists C++
1639 Number of Ways to Form a Target String Given a Dictionar C++
1642 Furthest Building You Can Reach C++
1647 Minimum Deletions to Make Character Frequencies Unique C++
1650 Lowest Common Ancestor of a Binary Tree III C++
1657 Determine if Two Strings Are Close C++
1664 Ways to Make a Fair Array C++
1751 Maximum Number of Events That Can Be Attended II C++
1776 Car Fleet II C++
1778 Shortest Path in a Hidden Grid C++
1802 Maximum Value at a Given Index in a Bounded Array C++
1813 Sentence Similarity III C++
1825 Finding MK Average C++
1871 Jump Game VII C++
1901 Find a Peak Element II C++
1929 Unique Email Addresses C++
1940 Longest Common Subsequence Between Sorted Arrays C++
1942 The Number of the Smallest Unoccupied Chair C++
1944 Number of Visible People in a Queue C++
1970 Last Day Where You Can Still Cross C++
2007 Find Original Array From Doubled Array C++
2023 Number of Pairs of Strings With Concatenation Equal to Target C++
2050 Parallel Courses III C++
2061 Number of Spaces Cleaning Robot Cleaned C++
2088 Count Fertile Pyramids in a Land C++
2089 Find Target Indices After Sorting Array C++
2092 Find All People With Secret C++
2101 Detonate the Maximum Bombs C++
2104 Sum of Subarray Ranges C++
2127 Maximum Employees to Be Invited to a Meeting C++
2149 Rearrange Array Elements by Sign C++
2158 Amount of New Area Painted Each Day C++
2167 Minimum Time to Remove All Cars Containing Illegal Goods C++
2195 Append K Integers With Minimal Sum C++
2221 Find Triangular Sum of an Array C++
2225 Find Players With Zero or One Losses C++
2251 Number of Flowers in Full Bloom C++
2265 Count Nodes Equal to Average of Subtree C++
2291 Maximum Profit From Trading Stocks C++
2328 Number of Increasing Paths in a Grid C++
2366 Minimum Replacements to Sort the Array C++
2369 Check if There is a Valid Partition For The Array C++
2385 Amount of Time for Binary Tree to Be Infected C++
2397 Maximum Rows Covered by Columns C++
2402 Meeting Rooms III C++
2406 Divide Intervals Into Minimum Number of Groups C++
2407 Longest Increasing Subsequence II C++
2419 Longest Subarray With Maximum Bitwise AND C++
2421 Number of Good Paths C++
2433 Find The Original Array of Prefix Xor C++
2448 Minimum Cost to Make Array Equal C++
2458 Height of Binary Tree After Subtree Removal Queries C++
2473 Minimum Cost to Buy Apples C++
2483 Minimum Penalty for a Shop C++
2486 Append Characters to String to Make Subsequence C++
2491 Divide Players Into Teams of Equal Skill C++
2519 Count the Number of K-Big Indices C++
2534 Time Taken to Cross the Door C++
2552 Count Increasing Quadruplets C++
2555 Maximize Win From Two Segments C++
2571 Minimum Operations to Reduce an Integer to 0 C++
2573 Find the String with LCP C++
2616 Minimize the Maximum Difference of Pairs C++
2659 Make Array Empty C++
2707 Extra Characters in a String C++
2709 Greatest Common Divisor Traversal C++
2713 Maximum Strictly Increasing Cells in a Matrix C++
2742 Painting the Walls C++
2765 Longest Alternating Subarray C++
2766 Relocate Marbles C++
2767 Partition String Into Minimum Beautiful Substrings C++
2768 Number of Black Blocks C++
2770 Maximum Number of Jumps to Reach the Last Index C++
2771 Longest Non-decreasing Subarray From Two Arrays C++
2778 Sum of Squares of Special Elements C++
2779 Maximum Beauty of an Array After Applying Operation C++
2780 Minimum Index of a Valid Split C++
2781 Length of the Longest Valid Substring C++
2788 Split Strings by Separator C++
2789 Largest Element in an Array after Merge Operations C++
2790 Maximum Number of Groups With Increasing Length C++
2798 Number of Employees Who Met the Target C++
2799 Count Complete Subarrays in an Array C++
2800 Shortest String That Contains Three Strings C++
2802 Find The K-th Lucky Number C++
2812 Find the Safest Path in a Grid C++
2816 Double a Number Represented as a Linked List C++
2838 Maximum Coins Heroes Can Collect C++
2842 Count K-Subsequences of a String With Maximum Beauty C++
2858 Minimum Edge Reversals So Every Node Is Reachable C++
2852 Sum of Remoteness of All Cells C++
2973 Find Number of Coins to Place in Tree Nodes C++
2948 Make Lexicographically Smallest Array by Swapping Elements C++
3062 Winner of the Linked List Game C++

About

LeetCode Solution

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published