9 releases

0.2.0 Nov 21, 2020
0.1.7 Aug 11, 2020

#1789 in Data structures

24 downloads per month

MIT/Apache

2MB
60K SLoC

Leetcode Solutions in Rust Docs Status Build Status

This project demostrates how to create Data Structures and to implement Algorithms using programming language Rust All the solutions here are crafted with love and their performance beats 99% of other solutions on the leetcode website. Tutorial videos will be added later.

Please subscribe to our Rust Gym Youtube Channel for future videos.

Data Structures
  • Stack & Queue ( Vec, VecDeque )
  • Linked List ( Option<Box> )
  • Hash Tables ( HashMap, HashSet )
  • Tree Tables ( BTreeMap, BTreeSet )
  • Binary Search Tree ( Option<Rc<RefCell>> )
  • Binary Heaps & Priority Queue ( BinaryHeap )
  • Graphs ( Vec<Vec> )
  • Union Find ( UnionFind )
  • Trie ( Trie )
Algorithms
  • Bit Manipulation & Numbers
  • Stability in Sorting
  • Heapsort
  • Binary Search
  • Kth Smallest Elements
  • Permutations
  • Subsets
  • BFS Graph
  • DFS Graph
  • Dijkstra’s Algorithm
  • Tree Traversals
    • BFS
    • DFS
      • in-order
      • pre-order
      • post-order
  • Topological Sort
  • Detect cycle in an undirected graph
  • Detect a cycle in a directed graph
  • Count connected components in a graph
  • Find strongly connected components in a graph

Coding Interview

Leetcode is a website where people–mostly software engineers–practice their coding skills. There are 1200+ questions (and growing), each with multiple solutions. Questions are ranked by level of difficulty: easy, medium, and hard. Within the last decade or so, the technical interview process has become formulaic and what some describe “unnatural” for engineers. What people are asked to perform in an interview–solving word or code based teasers, coding on a whiteboard, and being asked to produce clean optimized solutions in a short time frame–is not what they would experience in a daily work environment.

All Solutions

Easy 7/376 1.86%
id 376 Easy Questions Tags 369 Solutions
690 Employee Importance hash-table depth-first-search breadth-first-search
160 Intersection of Two Linked Lists linked-list
237 Delete Node in a Linked List linked-list
141 Linked List Cycle linked-list two-pointers
589 N-ary Tree Preorder Traversal tree
590 N-ary Tree Postorder Traversal tree
559 Maximum Depth of N-ary Tree tree depth-first-search breadth-first-search
1002 Find Common Characters array hash-table solution
1005 Maximize Sum Of Array After K Negations greedy solution
1009 Complement of Base 10 Integer math solution
100 Same Tree tree depth-first-search solution
1010 Pairs of Songs With Total Durations Divisible by 60 array solution
1013 Partition Array Into Three Parts With Equal Sum array solution
1018 Binary Prefix Divisible By 5 array solution
101 Symmetric Tree tree depth-first-search breadth-first-search solution
1021 Remove Outermost Parentheses stack solution
1022 Sum of Root To Leaf Binary Numbers tree solution
1025 Divisor Game math dynamic-programming solution
1030 Matrix Cells in Distance Order sort solution
1033 Moving Stones Until Consecutive brainteaser solution
1037 Valid Boomerang math solution
1046 Last Stone Weight heap greedy solution
1047 Remove All Adjacent Duplicates In String stack solution
104 Maximum Depth of Binary Tree tree depth-first-search solution
1051 Height Checker array solution
1056 Confusing Number math solution
1064 Fixed Point array binary-search solution
1065 Index Pairs of a String string trie solution
1071 Greatest Common Divisor of Strings string solution
1078 Occurrences After Bigram hash-table solution
107 Binary Tree Level Order Traversal II tree breadth-first-search solution
1085 Sum of Digits in the Minimum Number array solution
1086 High Five array hash-table sort solution
1089 Duplicate Zeros array solution
108 Convert Sorted Array to Binary Search Tree tree depth-first-search solution
1099 Two Sum Less Than K array two-pointers sort solution
1103 Distribute Candies to People math solution
1108 Defanging an IP Address string solution
110 Balanced Binary Tree tree depth-first-search solution
1118 Number of Days in a Month solution
1119 Remove Vowels from a String string solution
111 Minimum Depth of Binary Tree tree depth-first-search breadth-first-search solution
1122 Relative Sort Array array sort solution
1128 Number of Equivalent Domino Pairs array solution
112 Path Sum tree depth-first-search solution
1133 Largest Unique Number array hash-table solution
1134 Armstrong Number math solution
1137 N-th Tribonacci Number recursion solution
1150 Check If a Number Is Majority Element in a Sorted Array array binary-search solution
1154 Day of the Year math solution
1160 Find Words That Can Be Formed by Characters array hash-table solution
1165 Single-Row Keyboard string solution
1170 Compare Strings by Frequency of the Smallest Character array string solution
1175 Prime Arrangements math solution
1176 Diet Plan Performance array sliding-window solution
1180 Count Substrings with Only One Distinct Letter math string solution
1184 Distance Between Bus Stops array solution
1185 Day of the Week array solution
1189 Maximum Number of Balloons hash-table string solution
118 Pascal's Triangle array solution
1196 How Many Apples Can You Put into the Basket greedy solution
119 Pascal's Triangle II array solution
1200 Minimum Absolute Difference array solution
1207 Unique Number of Occurrences hash-table solution
1213 Intersection of Three Sorted Arrays hash-table two-pointers solution
1217 Minimum Cost to Move Chips to The Same Position array math greedy solution
121 Best Time to Buy and Sell Stock array dynamic-programming solution
1221 Split a String in Balanced Strings string greedy solution
1228 Missing Number In Arithmetic Progression math solution
122 Best Time to Buy and Sell Stock II array greedy solution
1232 Check If It Is a Straight Line array math geometry solution
1237 Find Positive Integer Solution for a Given Equation math binary-search solution
1243 Array Transformation array solution
1252 Cells with Odd Values in a Matrix array solution
125 Valid Palindrome two-pointers string solution
1260 Shift 2D Grid array solution
1266 Minimum Time Visiting All Points array geometry solution
1271 Hexspeak math string solution
1275 Find Winner on a Tic Tac Toe Game array solution
1281 Subtract the Product and Sum of Digits of an Integer math solution
1287 Element Appearing More Than 25% In Sorted Array array solution
1290 Convert Binary Number in a Linked List to Integer linked-list bit-manipulation solution
1295 Find Numbers with Even Number of Digits array solution
1299 Replace Elements with Greatest Element on Right Side array solution
1304 Find N Unique Integers Sum up to Zero array solution
1309 Decrypt String from Alphabet to Integer Mapping string solution
1313 Decompress Run-Length Encoded List array solution
1317 Convert Integer to the Sum of Two No-Zero Integers math solution
1323 Maximum 69 Number math solution
1331 Rank Transform of an Array array solution
1332 Remove Palindromic Subsequences string solution
1337 The K Weakest Rows in a Matrix array binary-search solution
1342 Number of Steps to Reduce a Number to Zero bit-manipulation solution
1346 Check If N and Its Double Exist array solution
1351 Count Negative Numbers in a Sorted Matrix array binary-search solution
1356 Sort Integers by The Number of 1 Bits sort bit-manipulation solution
1360 Number of Days Between Two Dates solution
1365 How Many Numbers Are Smaller Than the Current Number array hash-table solution
136 Single Number hash-table bit-manipulation solution
1370 Increasing Decreasing String string sort solution
1374 Generate a String With Characters That Have Odd Counts string solution
1380 Lucky Numbers in a Matrix array solution
1385 Find the Distance Value Between Two Arrays array solution
1389 Create Target Array in the Given Order array solution
1394 Find Lucky Integer in an Array array solution
1399 Count Largest Group array solution
13 Roman to Integer math string solution
1403 Minimum Subsequence in Non-Increasing Order greedy sort solution
1408 String Matching in an Array string solution
1413 Minimum Value to Get Positive Step by Step Sum array solution
1417 Reformat The String string solution
1422 Maximum Score After Splitting a String string solution
1426 Counting Elements array solution
1427 Perform String Shifts array math solution
1431 Kids With the Greatest Number of Candies array solution
1436 Destination City string solution
1441 Build an Array With Stack Operations stack solution
1446 Consecutive Characters string solution
1450 Number of Students Doing Homework at a Given Time array solution
1455 Check If a Word Occurs As a Prefix of Any Word in a Sentence string solution
1460 Make Two Arrays Equal by Reversing Sub-arrays array solution
1464 Maximum Product of Two Elements in an Array array solution
1469 Find All The Lonely Nodes tree depth-first-search solution
1470 Shuffle the Array array solution
1474 Delete N Nodes After M Nodes of a Linked List linked-list solution
1475 Final Prices With a Special Discount in a Shop array solution
1480 Running Sum of 1d Array array solution
1486 XOR Operation in an Array array bit-manipulation solution
1491 Average Salary Excluding the Minimum and Maximum Salary array sort solution
1496 Path Crossing string solution
14 Longest Common Prefix string solution
1502 Can Make Arithmetic Progression From Sequence array sort solution
1507 Reformat Date string solution
1512 Number of Good Pairs array hash-table math solution
1518 Water Bottles greedy solution
1523 Count Odd Numbers in an Interval Range math solution
1528 Shuffle String sort solution
1534 Count Good Triplets array solution
1539 Kth Missing Positive Number array hash-table solution
1544 Make The String Great string stack solution
1550 Three Consecutive Odds array solution
1556 Thousand Separator string solution
155 Min Stack stack design solution
1560 Most Visited Sector in a Circular Track array solution
1566 Detect Pattern of Length M Repeated K or More Times array solution
1572 Matrix Diagonal Sum array solution
1576 Replace All ?'s to Avoid Consecutive Repeating Characters string solution
157 Read N Characters Given Read4 string solution
1582 Special Positions in a Binary Matrix array solution
1588 Sum of All Odd Length Subarrays array solution
1592 Rearrange Spaces Between Words string solution
1598 Crawler Log Folder stack solution
1603 Design Parking System design solution
1608 Special Array With X Elements Greater Than or Equal X array solution
1614 Maximum Nesting Depth of the Parentheses string solution
1619 Mean of Array After Removing Some Elements array solution
1624 Largest Substring Between Two Equal Characters string solution
1629 Slowest Key array solution
1636 Sort Array by Increasing Frequency array sort solution
163 Missing Ranges array solution
1640 Check Array Formation Through Concatenation array sort solution
1646 Get Maximum in Generated Array array solution
1652 Defuse the Bomb array solution
1656 Design an Ordered Stream array design solution
167 Two Sum II - Input array is sorted array two-pointers binary-search solution
168 Excel Sheet Column Title math solution
169 Majority Element array divide-and-conquer bit-manipulation solution
170 Two Sum III - Data structure design hash-table design solution
171 Excel Sheet Column Number math solution
172 Factorial Trailing Zeroes math solution
190 Reverse Bits bit-manipulation solution
191 Number of 1 Bits bit-manipulation solution
198 House Robber dynamic-programming solution
1 Two Sum array hash-table solution
202 Happy Number hash-table math solution
203 Remove Linked List Elements linked-list solution
204 Count Primes hash-table math solution
205 Isomorphic Strings hash-table solution
206 Reverse Linked List linked-list solution
20 Valid Parentheses string stack solution
217 Contains Duplicate array hash-table solution
219 Contains Duplicate II array hash-table solution
21 Merge Two Sorted Lists linked-list solution
225 Implement Stack using Queues stack design solution
226 Invert Binary Tree tree solution
228 Summary Ranges array solution
231 Power of Two math bit-manipulation solution
232 Implement Queue using Stacks stack design solution
234 Palindrome Linked List linked-list two-pointers solution
235 Lowest Common Ancestor of a Binary Search Tree tree solution
242 Valid Anagram hash-table sort solution
243 Shortest Word Distance array solution
246 Strobogrammatic Number hash-table math solution
252 Meeting Rooms sort solution
257 Binary Tree Paths tree depth-first-search solution
258 Add Digits math solution
263 Ugly Number math solution
266 Palindrome Permutation hash-table solution
268 Missing Number array math bit-manipulation solution
26 Remove Duplicates from Sorted Array array two-pointers solution
270 Closest Binary Search Tree Value binary-search tree solution
276 Paint Fence dynamic-programming solution
278 First Bad Version binary-search solution
27 Remove Element array two-pointers solution
283 Move Zeroes array two-pointers solution
28 Implement strStr() two-pointers string solution
290 Word Pattern hash-table solution
292 Nim Game brainteaser minimax solution
293 Flip Game string solution
303 Range Sum Query - Immutable dynamic-programming solution
326 Power of Three math solution
339 Nested List Weight Sum depth-first-search solution
342 Power of Four bit-manipulation solution
344 Reverse String two-pointers string solution
345 Reverse Vowels of a String two-pointers string solution
346 Moving Average from Data Stream design queue solution
349 Intersection of Two Arrays hash-table two-pointers binary-search sort solution
350 Intersection of Two Arrays II hash-table two-pointers binary-search sort solution
359 Logger Rate Limiter hash-table design solution
35 Search Insert Position array binary-search solution
367 Valid Perfect Square math binary-search solution
374 Guess Number Higher or Lower binary-search solution
383 Ransom Note string solution
387 First Unique Character in a String hash-table string solution
389 Find the Difference hash-table bit-manipulation solution
38 Count and Say string solution
392 Is Subsequence binary-search dynamic-programming greedy solution
401 Binary Watch backtracking bit-manipulation solution
404 Sum of Left Leaves tree solution
405 Convert a Number to Hexadecimal bit-manipulation solution
408 Valid Word Abbreviation string solution
409 Longest Palindrome hash-table solution
412 Fizz Buzz solution
414 Third Maximum Number array solution
415 Add Strings string solution
422 Valid Word Square solution
434 Number of Segments in a String string solution
441 Arranging Coins math binary-search solution
448 Find All Numbers Disappeared in an Array array solution
453 Minimum Moves to Equal Array Elements math solution
455 Assign Cookies greedy solution
459 Repeated Substring Pattern string solution
461 Hamming Distance bit-manipulation solution
463 Island Perimeter hash-table solution
476 Number Complement bit-manipulation solution
482 License Key Formatting solution
485 Max Consecutive Ones array solution
492 Construct the Rectangle math solution
496 Next Greater Element I stack solution
500 Keyboard Row hash-table solution
501 Find Mode in Binary Search Tree tree solution
504 Base 7 solution
506 Relative Ranks solution
507 Perfect Number math solution
509 Fibonacci Number array solution
520 Detect Capital string solution
521 Longest Uncommon Subsequence I string brainteaser solution
530 Minimum Absolute Difference in BST tree solution
53 Maximum Subarray array divide-and-conquer dynamic-programming solution
541 Reverse String II string solution
543 Diameter of Binary Tree tree solution
551 Student Attendance Record I string solution
557 Reverse Words in a String III string solution
561 Array Partition I array solution
563 Binary Tree Tilt tree depth-first-search recursion solution
566 Reshape the Matrix array solution
572 Subtree of Another Tree tree solution
575 Distribute Candies hash-table solution
58 Length of Last Word string solution
594 Longest Harmonious Subsequence hash-table solution
598 Range Addition II math solution
599 Minimum Index Sum of Two Lists hash-table solution
604 Design Compressed String Iterator design solution
605 Can Place Flowers array solution
606 Construct String from Binary Tree string tree solution
617 Merge Two Binary Trees tree solution
628 Maximum Product of Three Numbers array math solution
637 Average of Levels in Binary Tree tree solution
643 Maximum Average Subarray I array solution
645 Set Mismatch hash-table math solution
653 Two Sum IV - Input is a BST tree solution
657 Robot Return to Origin string solution
661 Image Smoother array solution
665 Non-decreasing Array array solution
669 Trim a Binary Search Tree tree solution
66 Plus One array solution
671 Second Minimum Node In a Binary Tree tree solution
674 Longest Continuous Increasing Subsequence array solution
67 Add Binary math string solution
680 Valid Palindrome II string solution
682 Baseball Game stack solution
693 Binary Number with Alternating Bits bit-manipulation solution
696 Count Binary Substrings string solution
697 Degree of an Array array solution
69 Sqrt(x) math binary-search solution
700 Search in a Binary Search Tree tree solution
703 Kth Largest Element in a Stream heap design solution
704 Binary Search binary-search solution
705 Design HashSet hash-table design solution
706 Design HashMap hash-table design solution
709 To Lower Case string solution
70 Climbing Stairs dynamic-programming solution
716 Max Stack design solution
717 1-bit and 2-bit Characters array solution
720 Longest Word in Dictionary hash-table trie solution
724 Find Pivot Index array solution
728 Self Dividing Numbers math solution
733 Flood Fill depth-first-search solution
734 Sentence Similarity hash-table solution
744 Find Smallest Letter Greater Than Target binary-search solution
746 Min Cost Climbing Stairs array dynamic-programming solution
747 Largest Number At Least Twice of Others array solution
748 Shortest Completing Word hash-table solution
758 Bold Words in String string solution
760 Find Anagram Mappings hash-table solution
762 Prime Number of Set Bits in Binary Representation bit-manipulation solution
766 Toeplitz Matrix array solution
771 Jewels and Stones hash-table solution
783 Minimum Distance Between BST Nodes tree recursion solution
788 Rotated Digits string solution
796 Rotate String solution
7 Reverse Integer math solution
800 Similar RGB Color math string solution
804 Unique Morse Code Words string solution
806 Number of Lines To Write String solution
811 Subdomain Visit Count hash-table solution
812 Largest Triangle Area math solution
819 Most Common Word string solution
821 Shortest Distance to a Character solution
824 Goat Latin string solution
830 Positions of Large Groups array solution
832 Flipping an Image array solution
836 Rectangle Overlap math solution
83 Remove Duplicates from Sorted List linked-list solution
844 Backspace String Compare two-pointers stack solution
852 Peak Index in a Mountain Array binary-search solution
859 Buddy Strings string solution
860 Lemonade Change greedy solution
867 Transpose Matrix array solution
868 Binary Gap math solution
872 Leaf-Similar Trees tree depth-first-search solution
874 Walking Robot Simulation greedy solution
876 Middle of the Linked List linked-list solution
883 Projection Area of 3D Shapes math solution
884 Uncommon Words from Two Sentences hash-table solution
888 Fair Candy Swap array solution
88 Merge Sorted Array array two-pointers solution
892 Surface Area of 3D Shapes math geometry solution
893 Groups of Special-Equivalent Strings string solution
896 Monotonic Array array solution
897 Increasing Order Search Tree tree depth-first-search solution
905 Sort Array By Parity array solution
908 Smallest Range I math solution
914 X of a Kind in a Deck of Cards array math solution
917 Reverse Only Letters string solution
922 Sort Array By Parity II array sort solution
925 Long Pressed Name two-pointers string solution
929 Unique Email Addresses string solution
933 Number of Recent Calls queue solution
937 Reorder Data in Log Files string solution
938 Range Sum of BST tree depth-first-search recursion solution
941 Valid Mountain Array array solution
942 DI String Match math solution
944 Delete Columns to Make Sorted greedy solution
953 Verifying an Alien Dictionary hash-table solution
961 N-Repeated Element in Size 2N Array hash-table solution
965 Univalued Binary Tree tree solution
970 Powerful Integers hash-table math solution
976 Largest Perimeter Triangle math sort solution
977 Squares of a Sorted Array array two-pointers solution
985 Sum of Even Numbers After Queries array solution
989 Add to Array-Form of Integer array solution
993 Cousins in Binary Tree tree breadth-first-search solution
997 Find the Town Judge graph solution
999 Available Captures for Rook array solution
9 Palindrome Number math solution
Medium 29/804 3.61%
id 804 Medium Questions Tags 775 Solutions
427 Construct Quad Tree
558 Logical OR of Two Binary Grids Represented as Quad-Trees
1265 Print Immutable Linked List in Reverse
1506 Find Root of N-Ary Tree
1522 Diameter of N-Ary Tree
702 Search in a Sorted Array of Unknown Size binary-search
1236 Web Crawler depth-first-search breadth-first-search
133 Clone Graph depth-first-search breadth-first-search graph
284 Peeking Iterator design
673 Number of Longest Increasing Subsequence dynamic-programming
138 Copy List with Random Pointer hash-table linked-list
1612 Check If Two Expression Trees are Equivalent hash-table tree
1485 Clone Binary Tree With Random Pointer hash-table tree depth-first-search breadth-first-search
1490 Clone N-ary Tree hash-table tree depth-first-search breadth-first-search
708 Insert into a Sorted Circular Linked List linked-list
1634 Add Two Polynomials Represented as Linked Lists linked-list
430 Flatten a Multilevel Doubly Linked List linked-list depth-first-search
426 Convert Binary Search Tree to Sorted Doubly Linked List linked-list divide-and-conquer tree
142 Linked List Cycle II linked-list two-pointers
1618 Maximum Font to Fit a Sentence in a Screen string binary-search
510 Inorder Successor in BST II tree
1379 Find a Corresponding Node of a Binary Tree in a Clone of That Tree tree
1644 Lowest Common Ancestor of a Binary Tree II tree
1650 Lowest Common Ancestor of a Binary Tree III tree
429 N-ary Tree Level Order Traversal tree breadth-first-search
1602 Find Nearest Right Node in Binary Tree tree breadth-first-search
117 Populating Next Right Pointers in Each Node II tree depth-first-search
116 Populating Next Right Pointers in Each Node tree depth-first-search breadth-first-search
1628 Design an Expression Tree With Evaluate Function tree design
1003 Check If Word Is Valid After Substitutions string stack solution
1004 Max Consecutive Ones III two-pointers sliding-window solution
1006 Clumsy Factorial math solution
1007 Minimum Domino Rotations For Equal Row array greedy solution
1008 Construct Binary Search Tree from Preorder Traversal tree solution
1011 Capacity To Ship Packages Within D Days array binary-search solution
1014 Best Sightseeing Pair array solution
1015 Smallest Integer Divisible by K math solution
1016 Binary String With Substrings Representing 1 To N string solution
1017 Convert to Base -2 math solution
1019 Next Greater Node In Linked List linked-list stack solution
1020 Number of Enclaves depth-first-search solution
1023 Camelcase Matching string trie solution
1024 Video Stitching dynamic-programming solution
1026 Maximum Difference Between Node and Ancestor tree depth-first-search solution
1027 Longest Arithmetic Subsequence dynamic-programming solution
1029 Two City Scheduling greedy solution
102 Binary Tree Level Order Traversal tree breadth-first-search solution
1031 Maximum Sum of Two Non-Overlapping Subarrays array solution
1034 Coloring A Border depth-first-search solution
1035 Uncrossed Lines array solution
1038 Binary Search Tree to Greater Sum Tree binary-search-tree solution
1039 Minimum Score Triangulation of Polygon dynamic-programming solution
103 Binary Tree Zigzag Level Order Traversal stack tree breadth-first-search solution
1040 Moving Stones Until Consecutive II array sliding-window solution
1041 Robot Bounded In Circle math solution
1042 Flower Planting With No Adjacent graph solution
1043 Partition Array for Maximum Sum dynamic-programming solution
1048 Longest String Chain hash-table dynamic-programming solution
1049 Last Stone Weight II dynamic-programming solution
1052 Grumpy Bookstore Owner array sliding-window solution
1053 Previous Permutation With One Swap array greedy solution
1054 Distant Barcodes heap sort solution
1055 Shortest Way to Form String dynamic-programming greedy solution
1057 Campus Bikes greedy sort solution
1058 Minimize Rounding Error to Meet Target math dynamic-programming greedy solution
1059 All Paths from Source Lead to Destination depth-first-search graph solution
105 Construct Binary Tree from Preorder and Inorder Traversal array tree depth-first-search solution
1060 Missing Element in Sorted Array binary-search solution
1061 Lexicographically Smallest Equivalent String depth-first-search union-find solution
1062 Longest Repeating Substring string solution
1066 Campus Bikes II dynamic-programming backtracking solution
106 Construct Binary Tree from Inorder and Postorder Traversal array tree depth-first-search solution
1072 Flip Columns For Maximum Number of Equal Rows hash-table solution
1073 Adding Two Negabinary Numbers math solution
1079 Letter Tile Possibilities backtracking solution
1080 Insufficient Nodes in Root to Leaf Paths depth-first-search solution
1081 Smallest Subsequence of Distinct Characters string stack greedy solution
1087 Brace Expansion backtracking solution
1090 Largest Values From Labels hash-table greedy solution
1091 Shortest Path in Binary Matrix breadth-first-search solution
1093 Statistics from a Large Sample math two-pointers solution
1094 Car Pooling greedy solution
109 Convert Sorted List to Binary Search Tree linked-list depth-first-search solution
1100 Find K-Length Substrings With No Repeated Characters string sliding-window solution
1101 The Earliest Moment When Everyone Become Friends union-find solution
1102 Path With Maximum Minimum Value depth-first-search union-find graph solution
1104 Path In Zigzag Labelled Binary Tree math tree solution
1105 Filling Bookcase Shelves dynamic-programming solution
1109 Corporate Flight Bookings array math solution
1110 Delete Nodes And Return Forest tree depth-first-search solution
1111 Maximum Nesting Depth of Two Valid Parentheses Strings binary-search greedy solution
1120 Maximum Average Subtree tree solution
1123 Lowest Common Ancestor of Deepest Leaves tree depth-first-search solution
1124 Longest Well-Performing Interval stack solution
1129 Shortest Path with Alternating Colors breadth-first-search graph solution
1130 Minimum Cost Tree From Leaf Values dynamic-programming stack tree solution
1131 Maximum of Absolute Value Expression math bit-manipulation solution
1135 Connecting Cities With Minimum Cost union-find graph solution
1138 Alphabet Board Path hash-table string solution
1139 Largest 1-Bordered Square dynamic-programming solution
113 Path Sum II tree depth-first-search solution
1140 Stone Game II dynamic-programming solution
1143 Longest Common Subsequence dynamic-programming solution
1144 Decrease Elements To Make Array Zigzag array solution
1145 Binary Tree Coloring Game tree depth-first-search solution
1146 Snapshot Array array solution
114 Flatten Binary Tree to Linked List tree depth-first-search solution
1151 Minimum Swaps to Group All 1's Together array sliding-window solution
1152 Analyze User Website Visit Pattern array hash-table sort solution
1155 Number of Dice Rolls With Target Sum dynamic-programming solution
1156 Swap For Longest Repeated Character Substring string solution
1161 Maximum Level Sum of a Binary Tree tree breadth-first-search solution
1162 As Far from Land as Possible breadth-first-search graph solution
1166 Design File System hash-table design solution
1167 Minimum Cost to Connect Sticks greedy solution
1169 Invalid Transactions array string solution
1171 Remove Zero Sum Consecutive Nodes from Linked List linked-list solution
1177 Can Make Palindrome from Substring array string solution
1181 Before and After Puzzle string solution
1182 Shortest Distance to Target Color binary-search solution
1186 Maximum Subarray Sum with One Deletion dynamic-programming solution
1190 Reverse Substrings Between Each Pair of Parentheses stack solution
1191 K-Concatenation Maximum Sum dynamic-programming solution
1197 Minimum Knight Moves breadth-first-search solution
1198 Find Smallest Common Element in All Rows hash-table binary-search solution
11 Container With Most Water array two-pointers solution
1201 Ugly Number III math binary-search solution
1202 Smallest String With Swaps array union-find solution
1208 Get Equal Substrings Within Budget array sliding-window solution
1209 Remove All Adjacent Duplicates in String II stack solution
120 Triangle array dynamic-programming solution
1214 Two Sum BSTs binary-search-tree solution
1215 Stepping Numbers backtracking solution
1218 Longest Arithmetic Subsequence of Given Difference math dynamic-programming solution
1219 Path with Maximum Gold backtracking solution
1222 Queens That Can Attack the King array solution
1223 Dice Roll Simulation dynamic-programming solution
1227 Airplane Seat Assignment Probability math dynamic-programming brainteaser solution
1229 Meeting Scheduler line-sweep solution
1230 Toss Strange Coins math dynamic-programming solution
1233 Remove Sub-Folders from the Filesystem array string solution
1234 Replace the Substring for Balanced String two-pointers string solution
1238 Circular Permutation in Binary Representation math solution
1239 Maximum Length of a Concatenated String with Unique Characters backtracking bit-manipulation solution
1244 Design A Leaderboard hash-table sort design solution
1245 Tree Diameter tree depth-first-search breadth-first-search solution
1247 Minimum Swaps to Make Strings Equal string greedy solution
1248 Count Number of Nice Subarrays two-pointers solution
1249 Minimum Remove to Make Valid Parentheses string stack solution
1253 Reconstruct a 2-Row Binary Matrix math greedy solution
1254 Number of Closed Islands depth-first-search solution
1256 Encode Number math bit-manipulation solution
1257 Smallest Common Region tree solution
1258 Synonymous Sentences backtracking solution
1261 Find Elements in a Contaminated Binary Tree hash-table tree solution
1262 Greatest Sum Divisible by Three dynamic-programming solution
1267 Count Servers that Communicate array graph solution
1268 Search Suggestions System string solution
1272 Remove Interval math line-sweep solution
1273 Delete Tree Nodes dynamic-programming depth-first-search solution
1276 Number of Burgers with No Waste of Ingredients math greedy solution
1277 Count Square Submatrices with All Ones array dynamic-programming solution
127 Word Ladder breadth-first-search solution
1282 Group the People Given the Group Size They Belong To greedy solution
1283 Find the Smallest Divisor Given a Threshold binary-search solution
1286 Iterator for Combination backtracking design solution
1288 Remove Covered Intervals greedy sort line-sweep solution
1291 Sequential Digits backtracking solution
1292 Maximum Side Length of a Square with Sum Less than or Equal to Threshold array binary-search solution
1296 Divide Array in Sets of K Consecutive Numbers array greedy solution
1297 Maximum Number of Occurrences of a Substring string bit-manipulation solution
129 Sum Root to Leaf Numbers tree depth-first-search solution
12 Integer to Roman math string solution
1300 Sum of Mutated Array Closest to Target array binary-search solution
1302 Deepest Leaves Sum tree depth-first-search solution
1305 All Elements in Two Binary Search Trees sort tree solution
1306 Jump Game III breadth-first-search graph solution
130 Surrounded Regions depth-first-search breadth-first-search union-find solution
1310 XOR Queries of a Subarray bit-manipulation solution
1311 Get Watched Videos by Your Friends hash-table string breadth-first-search solution
1314 Matrix Block Sum dynamic-programming solution
1315 Sum of Nodes with Even-Valued Grandparent tree depth-first-search solution
1318 Minimum Flips to Make a OR b Equal to c bit-manipulation solution
1319 Number of Operations to Make Network Connected depth-first-search breadth-first-search union-find solution
131 Palindrome Partitioning backtracking solution
1324 Print Words Vertically string solution
1325 Delete Leaves With a Given Value tree solution
1328 Break a Palindrome string solution
1329 Sort the Matrix Diagonally array sort solution
1333 Filter Restaurants by Vegan-Friendly, Price and Distance array sort solution
1334 Find the City With the Smallest Number of Neighbors at a Threshold Distance graph solution
1338 Reduce Array Size to The Half array greedy solution
1339 Maximum Product of Splitted Binary Tree dynamic-programming tree depth-first-search solution
1343 Number of Sub-arrays of Size K and Average Greater than or Equal to Threshold array solution
1344 Angle Between Hands of a Clock math solution
1347 Minimum Number of Steps to Make Two Strings Anagram string solution
1348 Tweet Counts Per Frequency design solution
134 Gas Station greedy solution
1352 Product of the Last K Numbers array design solution
1353 Maximum Number of Events That Can Be Attended greedy sort segment-tree solution
1357 Apply Discount Every n Orders design solution
1358 Number of Substrings Containing All Three Characters string solution
1361 Validate Binary Tree Nodes graph solution
1362 Closest Divisors math solution
1366 Rank Teams by Votes array sort solution
1367 Linked List in Binary Tree linked-list dynamic-programming tree solution
1371 Find the Longest Substring Containing Vowels in Even Counts string solution
1372 Longest ZigZag Path in a Binary Tree dynamic-programming tree solution
1375 Bulb Switcher III array solution
1376 Time Needed to Inform All Employees depth-first-search solution
137 Single Number II bit-manipulation solution
1381 Design a Stack With Increment Operation stack design solution
1382 Balance a Binary Search Tree binary-search-tree solution
1386 Cinema Seat Allocation array greedy solution
1387 Sort Integers by The Power Value sort graph solution
1390 Four Divisors math solution
1391 Check if There is a Valid Path in a Grid depth-first-search breadth-first-search solution
1395 Count Number of Teams array solution
1396 Design Underground System design solution
139 Word Break dynamic-programming solution
1400 Construct K Palindrome Strings greedy solution
1401 Circle and Rectangle Overlapping geometry solution
1404 Number of Steps to Reduce a Number in Binary Representation to One string bit-manipulation solution
1405 Longest Happy String dynamic-programming greedy solution
1409 Queries on a Permutation With Key array solution
1410 HTML Entity Parser string stack solution
1414 Find the Minimum Number of Fibonacci Numbers Whose Sum Is K array greedy solution
1415 The k-th Lexicographical String of All Happy Strings of Length n backtracking solution
1418 Display Table of Food Orders in a Restaurant hash-table solution
1419 Minimum Number of Frogs Croaking string solution
1423 Maximum Points You Can Obtain from Cards array dynamic-programming sliding-window solution
1424 Diagonal Traverse II array sort solution
1428 Leftmost Column with at Least a One array solution
1429 First Unique Number hash-table design solution
1430 Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree tree solution
1432 Max Difference You Can Get From Changing an Integer string solution
1433 Check If a String Can Break Another String string greedy solution
1437 Check If All 1's Are at Least Length K Places Away array solution
1438 Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit array sliding-window solution
143 Reorder List linked-list solution
1442 Count Triplets That Can Form Two Arrays of Equal XOR array math bit-manipulation solution
1443 Minimum Time to Collect All Apples in a Tree tree depth-first-search solution
1447 Simplified Fractions math solution
1448 Count Good Nodes in Binary Tree tree depth-first-search solution
144 Binary Tree Preorder Traversal stack tree solution
1451 Rearrange Words in a Sentence string sort solution
1452 People Whose List of Favorite Companies Is Not a Subset of Another List string sort solution
1456 Maximum Number of Vowels in a Substring of Given Length string sliding-window solution
1457 Pseudo-Palindromic Paths in a Binary Tree bit-manipulation tree depth-first-search solution
145 Binary Tree Postorder Traversal stack tree solution
1461 Check If a String Contains All Binary Codes of Size K string bit-manipulation solution
1462 Course Schedule IV graph solution
1465 Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts array solution
1466 Reorder Routes to Make All Paths Lead to the City Zero tree depth-first-search solution
146 LRU Cache design solution
1471 The k Strongest Values in an Array array sort solution
1472 Design Browser History design solution
1476 Subrectangle Queries array solution
1477 Find Two Non-overlapping Sub-arrays Each With Target Sum dynamic-programming solution
147 Insertion Sort List linked-list sort solution
1481 Least Number of Unique Integers after K Removals array sort solution
1482 Minimum Number of Days to Make m Bouquets array binary-search solution
1487 Making File Names Unique hash-table string solution
1488 Avoid Flood in The City array hash-table solution
148 Sort List linked-list sort solution
1492 The kth Factor of n math solution
1493 Longest Subarray of 1's After Deleting One Element array solution
1497 Check If Array Pairs Are Divisible by k array math greedy solution
1498 Number of Subsequences That Satisfy the Given Sum Condition sort sliding-window solution
1500 Design a File Sharing System array design solution
1503 Last Moment Before All Ants Fall Out of a Plank array brainteaser solution
1504 Count Submatrices With All Ones dynamic-programming solution
1508 Range Sum of Sorted Subarray Sums array sort solution
1509 Minimum Difference Between Largest and Smallest Value in Three Moves array sort solution
150 Evaluate Reverse Polish Notation stack solution
1513 Number of Substrings With Only 1s math string solution
1514 Path with Maximum Probability graph solution
1519 Number of Nodes in the Sub-Tree With the Same Label depth-first-search breadth-first-search solution
151 Reverse Words in a String string solution
1524 Number of Sub-arrays With Odd Sum array math solution
1525 Number of Good Ways to Split a String string bit-manipulation solution
1529 Bulb Switcher IV string solution
152 Maximum Product Subarray array dynamic-programming solution
1530 Number of Good Leaf Nodes Pairs tree depth-first-search solution
1533 Find the Index of the Large Integer binary-search solution
1535 Find the Winner of an Array Game array solution
1536 Minimum Swaps to Arrange a Binary Grid greedy solution
1538 Guess the Majority in a Hidden Array solution
153 Find Minimum in Rotated Sorted Array array binary-search solution
1540 Can Convert String in K Moves string greedy solution
1541 Minimum Insertions to Balance a Parentheses String string stack solution
1545 Find Kth Bit in Nth Binary String string solution
1546 Maximum Number of Non-Overlapping Subarrays With Sum Equals Target dynamic-programming solution
1551 Minimum Operations to Make Array Equal math solution
1552 Magnetic Force Between Two Balls array binary-search solution
1554 Strings Differ by One Character solution
1557 Minimum Number of Vertices to Reach All Nodes graph solution
1558 Minimum Numbers of Function Calls to Make Target Array greedy solution
1561 Maximum Number of Coins You Can Get sort solution
1562 Find Latest Group of Size M binary-search solution
1564 Put Boxes Into the Warehouse I greedy solution
1567 Maximum Length of Subarray With Positive Product greedy solution
156 Binary Tree Upside Down tree solution
1570 Dot Product of Two Sparse Vectors array hash-table two-pointers solution
1573 Number of Ways to Split a String string solution
1574 Shortest Subarray to be Removed to Make Array Sorted array binary-search solution
1577 Number of Ways Where Square of Number Is Equal to Product of Two Numbers hash-table math solution
1578 Minimum Deletion Cost to Avoid Repeating Letters greedy solution
1580 Put Boxes Into the Warehouse II greedy solution
1583 Count Unhappy Friends array solution
1584 Min Cost to Connect All Points union-find solution
1586 Binary Search Tree Iterator II tree design solution
1589 Maximum Sum Obtained of Any Permutation greedy solution
1590 Make Sum Divisible by P array hash-table math binary-search solution
1593 Split a String Into the Max Number of Unique Substrings backtracking solution
1594 Maximum Non Negative Product in a Matrix dynamic-programming greedy solution
1599 Maximum Profit of Operating a Centennial Wheel greedy solution
159 Longest Substring with At Most Two Distinct Characters hash-table two-pointers string sliding-window solution
15 3Sum array two-pointers solution
1600 Throne Inheritance tree design solution
1604 Alert Using Same Key-Card Three or More Times in a One Hour Period string ordered-map solution
1605 Find Valid Matrix Given Row and Column Sums greedy solution
1609 Even Odd Tree tree solution
1615 Maximal Network Rank graph solution
1616 Split Two Strings to Make Palindrome two-pointers string greedy solution
161 One Edit Distance string solution
1620 Coordinate With Maximum Network Quality greedy solution
1621 Number of Sets of K Non-Overlapping Line Segments dynamic-programming solution
1625 Lexicographically Smallest String After Applying Operations depth-first-search breadth-first-search solution
1626 Best Team With No Conflicts dynamic-programming solution
162 Find Peak Element array binary-search solution
1630 Arithmetic Subarrays sort solution
1631 Path With Minimum Effort binary-search depth-first-search union-find graph solution
1637 Widest Vertical Area Between Two Points Containing No Points sort solution
1638 Count Substrings That Differ by One Character hash-table string trie rolling-hash solution
1641 Count Sorted Vowel Strings math dynamic-programming backtracking solution
1642 Furthest Building You Can Reach binary-search heap solution
1647 Minimum Deletions to Make Character Frequencies Unique greedy sort solution
1648 Sell Diminishing-Valued Colored Balls math greedy sort solution
1653 Minimum Deletions to Make String Balanced string greedy solution
1654 Minimum Jumps to Reach Home dynamic-programming breadth-first-search solution
1657 Determine if Two Strings Are Close greedy solution
1658 Minimum Operations to Reduce X to Zero two-pointers binary-search greedy solution
165 Compare Version Numbers string solution
166 Fraction to Recurring Decimal hash-table math solution
16 3Sum Closest array two-pointers solution
173 Binary Search Tree Iterator stack tree design solution
179 Largest Number sort solution
17 Letter Combinations of a Phone Number string backtracking solution
186 Reverse Words in a String II string solution
187 Repeated DNA Sequences hash-table bit-manipulation solution
189 Rotate Array array solution
18 4Sum array hash-table two-pointers solution
199 Binary Tree Right Side View tree depth-first-search breadth-first-search solution
19 Remove Nth Node From End of List linked-list two-pointers solution
200 Number of Islands depth-first-search breadth-first-search union-find solution
201 Bitwise AND of Numbers Range bit-manipulation solution
207 Course Schedule depth-first-search breadth-first-search graph topological-sort solution
208 Implement Trie (Prefix Tree) design trie solution
209 Minimum Size Subarray Sum array two-pointers binary-search solution
210 Course Schedule II depth-first-search breadth-first-search graph topological-sort solution
211 Design Add and Search Words Data Structure backtracking design trie solution
213 House Robber II dynamic-programming solution
215 Kth Largest Element in an Array divide-and-conquer heap solution
216 Combination Sum III array backtracking solution
220 Contains Duplicate III sort ordered-map solution
221 Maximal Square dynamic-programming solution
222 Count Complete Tree Nodes binary-search tree solution
223 Rectangle Area math solution
227 Basic Calculator II string stack solution
229 Majority Element II array solution
22 Generate Parentheses string backtracking solution
230 Kth Smallest Element in a BST binary-search tree solution
236 Lowest Common Ancestor of a Binary Tree tree solution
238 Product of Array Except Self array solution
240 Search a 2D Matrix II binary-search divide-and-conquer solution
241 Different Ways to Add Parentheses divide-and-conquer solution
244 Shortest Word Distance II hash-table design solution
245 Shortest Word Distance III array solution
247 Strobogrammatic Number II math recursion solution
249 Group Shifted Strings hash-table string solution
24 Swap Nodes in Pairs linked-list solution
250 Count Univalue Subtrees tree solution
251 Flatten 2D Vector design solution
253 Meeting Rooms II heap greedy sort solution
254 Factor Combinations backtracking solution
255 Verify Preorder Sequence in Binary Search Tree stack tree solution
256 Paint House dynamic-programming solution
259 3Sum Smaller array two-pointers solution
260 Single Number III bit-manipulation solution
261 Graph Valid Tree depth-first-search breadth-first-search union-find graph solution
264 Ugly Number II math dynamic-programming heap solution
267 Palindrome Permutation II backtracking solution
271 Encode and Decode Strings string solution
274 H-Index hash-table sort solution
275 H-Index II binary-search solution
277 Find the Celebrity array solution
279 Perfect Squares math dynamic-programming breadth-first-search solution
280 Wiggle Sort array sort solution
281 Zigzag Iterator design solution
285 Inorder Successor in BST tree solution
286 Walls and Gates breadth-first-search solution
287 Find the Duplicate Number array two-pointers binary-search solution
288 Unique Word Abbreviation hash-table design solution
289 Game of Life array solution
294 Flip Game II backtracking minimax solution
298 Binary Tree Longest Consecutive Sequence tree solution
299 Bulls and Cows hash-table solution
29 Divide Two Integers math binary-search solution
2 Add Two Numbers linked-list math solution
300 Longest Increasing Subsequence binary-search dynamic-programming solution
304 Range Sum Query 2D - Immutable dynamic-programming solution
306 Additive Number backtracking solution
307 Range Sum Query - Mutable binary-indexed-tree segment-tree solution
309 Best Time to Buy and Sell Stock with Cooldown dynamic-programming solution
310 Minimum Height Trees breadth-first-search graph solution
311 Sparse Matrix Multiplication hash-table solution
313 Super Ugly Number math heap solution
314 Binary Tree Vertical Order Traversal depth-first-search breadth-first-search solution
316 Remove Duplicate Letters string stack greedy solution
318 Maximum Product of Word Lengths bit-manipulation solution
319 Bulb Switcher math brainteaser solution
31 Next Permutation array solution
320 Generalized Abbreviation backtracking bit-manipulation solution
322 Coin Change dynamic-programming solution
323 Number of Connected Components in an Undirected Graph depth-first-search breadth-first-search union-find graph solution
324 Wiggle Sort II sort solution
325 Maximum Size Subarray Sum Equals k hash-table solution
328 Odd Even Linked List linked-list solution
331 Verify Preorder Serialization of a Binary Tree stack solution
332 Reconstruct Itinerary depth-first-search graph solution
333 Largest BST Subtree tree solution
334 Increasing Triplet Subsequence solution
337 House Robber III dynamic-programming tree depth-first-search solution
338 Counting Bits dynamic-programming bit-manipulation solution
33 Search in Rotated Sorted Array array binary-search solution
341 Flatten Nested List Iterator stack design solution
343 Integer Break math dynamic-programming solution
347 Top K Frequent Elements hash-table heap solution
348 Design Tic-Tac-Toe design solution
34 Find First and Last Position of Element in Sorted Array array binary-search solution
351 Android Unlock Patterns dynamic-programming backtracking solution
353 Design Snake Game design queue solution
355 Design Twitter hash-table heap design solution
356 Line Reflection hash-table math solution
357 Count Numbers with Unique Digits math dynamic-programming backtracking solution
360 Sort Transformed Array math two-pointers sort solution
361 Bomb Enemy dynamic-programming solution
362 Design Hit Counter design solution
364 Nested List Weight Sum II depth-first-search solution
365 Water and Jug Problem math solution
366 Find Leaves of Binary Tree tree depth-first-search solution
368 Largest Divisible Subset math dynamic-programming solution
369 Plus One Linked List linked-list solution
36 Valid Sudoku hash-table solution
370 Range Addition array solution
371 Sum of Two Integers bit-manipulation solution
372 Super Pow math solution
373 Find K Pairs with Smallest Sums heap solution
375 Guess Number Higher or Lower II dynamic-programming minimax solution
376 Wiggle Subsequence dynamic-programming greedy solution
377 Combination Sum IV dynamic-programming solution
378 Kth Smallest Element in a Sorted Matrix binary-search heap solution
379 Design Phone Directory linked-list design solution
380 Insert Delete GetRandom O(1) array hash-table design solution
382 Linked List Random Node reservoir-sampling solution
384 Shuffle an Array solution
385 Mini Parser string stack solution
386 Lexicographical Numbers solution
388 Longest Absolute File Path solution
390 Elimination Game solution
393 UTF-8 Validation bit-manipulation solution
394 Decode String stack depth-first-search solution
395 Longest Substring with At Least K Repeating Characters solution
396 Rotate Function math solution
397 Integer Replacement math bit-manipulation solution
398 Random Pick Index reservoir-sampling solution
399 Evaluate Division union-find graph solution
39 Combination Sum array backtracking solution
3 Longest Substring Without Repeating Characters hash-table two-pointers string sliding-window solution
400 Nth Digit math solution
402 Remove K Digits stack greedy solution
406 Queue Reconstruction by Height greedy solution
40 Combination Sum II array backtracking solution
413 Arithmetic Slices math dynamic-programming solution
416 Partition Equal Subset Sum dynamic-programming solution
417 Pacific Atlantic Water Flow depth-first-search breadth-first-search solution
418 Sentence Screen Fitting dynamic-programming solution
419 Battleships in a Board solution
421 Maximum XOR of Two Numbers in an Array bit-manipulation trie solution
423 Reconstruct Original Digits from English math solution
424 Longest Repeating Character Replacement two-pointers sliding-window solution
433 Minimum Genetic Mutation solution
435 Non-overlapping Intervals greedy solution
436 Find Right Interval binary-search solution
437 Path Sum III tree solution
438 Find All Anagrams in a String hash-table solution
439 Ternary Expression Parser stack depth-first-search solution
43 Multiply Strings math string solution
442 Find All Duplicates in an Array array solution
443 String Compression string solution
444 Sequence Reconstruction graph topological-sort solution
445 Add Two Numbers II linked-list solution
447 Number of Boomerangs hash-table math solution
449 Serialize and Deserialize BST tree solution
450 Delete Node in a BST tree solution
451 Sort Characters By Frequency hash-table heap solution
452 Minimum Number of Arrows to Burst Balloons greedy sort solution
454 4Sum II hash-table binary-search solution
456 132 Pattern stack solution
457 Circular Array Loop array two-pointers solution
462 Minimum Moves to Equal Array Elements II math solution
464 Can I Win dynamic-programming minimax solution
467 Unique Substrings in Wraparound String dynamic-programming solution
468 Validate IP Address string solution
469 Convex Polygon math solution
46 Permutations backtracking solution
470 Implement Rand10() Using Rand7() random rejection-sampling solution
473 Matchsticks to Square depth-first-search solution
474 Ones and Zeroes dynamic-programming solution
475 Heaters binary-search solution
477 Total Hamming Distance bit-manipulation solution
478 Generate Random Point in a Circle math random rejection-sampling solution
47 Permutations II backtracking solution
481 Magical String solution
484 Find Permutation greedy solution
486 Predict the Winner dynamic-programming minimax solution
487 Max Consecutive Ones II two-pointers solution
48 Rotate Image array solution
490 The Maze depth-first-search breadth-first-search solution
491 Increasing Subsequences depth-first-search solution
494 Target Sum dynamic-programming depth-first-search solution
495 Teemo Attacking array solution
497 Random Point in Non-overlapping Rectangles binary-search random solution
498 Diagonal Traverse solution
49 Group Anagrams hash-table string solution
503 Next Greater Element II stack solution
505 The Maze II depth-first-search breadth-first-search solution
508 Most Frequent Subtree Sum hash-table tree solution
50 Pow(x, n) math binary-search solution
513 Find Bottom Left Tree Value tree depth-first-search breadth-first-search solution
515 Find Largest Value in Each Tree Row tree depth-first-search breadth-first-search solution
516 Longest Palindromic Subsequence dynamic-programming solution
518 Coin Change 2 solution
519 Random Flip Matrix random solution
522 Longest Uncommon Subsequence II string solution
523 Continuous Subarray Sum math dynamic-programming solution
524 Longest Word in Dictionary through Deleting two-pointers sort solution
525 Contiguous Array hash-table solution
526 Beautiful Arrangement backtracking solution
528 Random Pick with Weight binary-search random solution
529 Minesweeper depth-first-search breadth-first-search solution
531 Lonely Pixel I array depth-first-search solution
532 K-diff Pairs in an Array array two-pointers solution
533 Lonely Pixel II array solution
535 Encode and Decode TinyURL hash-table math solution
536 Construct Binary Tree from String string tree solution
537 Complex Number Multiplication math string solution
538 Convert BST to Greater Tree tree solution
539 Minimum Time Difference string solution
540 Single Element in a Sorted Array solution
542 01 Matrix depth-first-search breadth-first-search solution
544 Output Contest Matches string recursion solution
545 Boundary of Binary Tree tree solution
547 Friend Circles depth-first-search union-find solution
548 Split Array with Equal Sum array solution
549 Binary Tree Longest Consecutive Sequence II tree solution
54 Spiral Matrix array solution
553 Optimal Division math string solution
554 Brick Wall hash-table solution
555 Split Concatenated Strings string solution
556 Next Greater Element III string solution
55 Jump Game array greedy solution
560 Subarray Sum Equals K array hash-table solution
562 Longest Line of Consecutive One in Matrix array solution
565 Array Nesting array solution
567 Permutation in String two-pointers sliding-window solution
56 Merge Intervals array sort solution
573 Squirrel Simulation math solution
576 Out of Boundary Paths dynamic-programming depth-first-search solution
57 Insert Interval array sort solution
581 Shortest Unsorted Continuous Subarray array solution
582 Kill Process tree queue solution
583 Delete Operation for Two Strings string solution
592 Fraction Addition and Subtraction math solution
593 Valid Square math solution
59 Spiral Matrix II array solution
5 Longest Palindromic Substring string dynamic-programming solution
609 Find Duplicate File in System hash-table string solution
611 Valid Triangle Number array solution
616 Add Bold Tag in String string solution
61 Rotate List linked-list two-pointers solution
621 Task Scheduler array greedy queue solution
622 Design Circular Queue design queue solution
623 Add One Row to Tree tree solution
624 Maximum Distance in Arrays array hash-table solution
625 Minimum Factorization math recursion solution
62 Unique Paths array dynamic-programming solution
633 Sum of Square Numbers math solution
634 Find the Derangement of An Array math solution
635 Design Log Storage System string design solution
636 Exclusive Time of Functions stack solution
638 Shopping Offers dynamic-programming depth-first-search solution
63 Unique Paths II array dynamic-programming solution
640 Solve the Equation math solution
641 Design Circular Deque design queue solution
646 Maximum Length of Pair Chain dynamic-programming solution
647 Palindromic Substrings string dynamic-programming solution
648 Replace Words hash-table trie solution
649 Dota2 Senate greedy solution
64 Minimum Path Sum array dynamic-programming solution
650 2 Keys Keyboard dynamic-programming solution
651 4 Keys Keyboard math dynamic-programming greedy solution
652 Find Duplicate Subtrees tree solution
654 Maximum Binary Tree tree solution
655 Print Binary Tree tree solution
658 Find K Closest Elements binary-search solution
659 Split Array into Consecutive Subsequences heap greedy solution
662 Maximum Width of Binary Tree tree solution
663 Equal Tree Partition tree solution
666 Path Sum IV tree solution
667 Beautiful Arrangement II array solution
670 Maximum Swap array math solution
672 Bulb Switcher II math solution
676 Implement Magic Dictionary hash-table trie solution
677 Map Sum Pairs trie solution
678 Valid Parenthesis String string solution
681 Next Closest Time string solution
684 Redundant Connection tree union-find graph solution
686 Repeated String Match string solution
687 Longest Univalue Path tree recursion solution
688 Knight Probability in Chessboard dynamic-programming solution
692 Top K Frequent Words hash-table heap trie solution
694 Number of Distinct Islands hash-table depth-first-search solution
695 Max Area of Island array depth-first-search solution
698 Partition to K Equal Sum Subsets dynamic-programming recursion solution
6 ZigZag Conversion string solution
701 Insert into a Binary Search Tree tree solution
707 Design Linked List linked-list design solution
712 Minimum ASCII Delete Sum for Two Strings dynamic-programming solution
713 Subarray Product Less Than K array two-pointers solution
714 Best Time to Buy and Sell Stock with Transaction Fee array dynamic-programming greedy solution
718 Maximum Length of Repeated Subarray array hash-table binary-search dynamic-programming solution
71 Simplify Path string stack solution
721 Accounts Merge depth-first-search union-find solution
722 Remove Comments string solution
723 Candy Crush array two-pointers solution
725 Split Linked List in Parts linked-list solution
729 My Calendar I array solution
731 My Calendar II ordered-map solution
735 Asteroid Collision stack solution
737 Sentence Similarity II depth-first-search union-find solution
738 Monotone Increasing Digits greedy solution
739 Daily Temperatures hash-table stack solution
73 Set Matrix Zeroes array solution
740 Delete and Earn dynamic-programming solution
742 Closest Leaf in a Binary Tree tree solution
743 Network Delay Time heap depth-first-search breadth-first-search graph solution
74 Search a 2D Matrix array binary-search solution
750 Number Of Corner Rectangles dynamic-programming solution
751 IP to CIDR bit-manipulation solution
752 Open the Lock breadth-first-search solution
754 Reach a Number math solution
755 Pour Water array solution
756 Pyramid Transition Matrix bit-manipulation depth-first-search solution
75 Sort Colors array two-pointers sort solution
763 Partition Labels two-pointers greedy solution
764 Largest Plus Sign dynamic-programming solution
767 Reorganize String string heap greedy sort solution
769 Max Chunks To Make Sorted array solution
775 Global and Local Inversions array math solution
776 Split BST tree recursion solution
777 Swap Adjacent in LR String brainteaser solution
779 K-th Symbol in Grammar recursion solution
77 Combinations backtracking solution
781 Rabbits in Forest hash-table math solution
784 Letter Case Permutation backtracking bit-manipulation solution
785 Is Graph Bipartite? depth-first-search breadth-first-search graph solution
787 Cheapest Flights Within K Stops dynamic-programming heap breadth-first-search solution
789 Escape The Ghosts math solution
78 Subsets array backtracking bit-manipulation solution
790 Domino and Tromino Tiling dynamic-programming solution
791 Custom Sort String string solution
792 Number of Matching Subsequences array solution
794 Valid Tic-Tac-Toe State math recursion solution
795 Number of Subarrays with Bounded Maximum array solution
797 All Paths From Source to Target backtracking depth-first-search graph solution
799 Champagne Tower dynamic-programming solution
79 Word Search array backtracking solution
801 Minimum Swaps To Make Sequences Increasing dynamic-programming solution
802 Find Eventual Safe States depth-first-search graph solution
807 Max Increase to Keep City Skyline solution
808 Soup Servings dynamic-programming solution
809 Expressive Words string solution
80 Remove Duplicates from Sorted Array II array two-pointers solution
813 Largest Sum of Averages dynamic-programming solution
814 Binary Tree Pruning tree solution
816 Ambiguous Coordinates string solution
817 Linked List Components linked-list solution
81 Search in Rotated Sorted Array II array binary-search solution
820 Short Encoding of Words solution
822 Card Flipping Game solution
823 Binary Trees With Factors solution
825 Friends Of Appropriate Ages array solution
826 Most Profit Assigning Work two-pointers solution
82 Remove Duplicates from Sorted List II linked-list solution
831 Masking Personal Information string solution
833 Find And Replace in String string solution
835 Image Overlap array solution
837 New 21 Game dynamic-programming solution
838 Push Dominoes two-pointers dynamic-programming solution
840 Magic Squares In Grid array solution
841 Keys and Rooms depth-first-search graph solution
842 Split Array into Fibonacci Sequence string backtracking greedy solution
845 Longest Mountain in Array two-pointers solution
846 Hand of Straights ordered-map solution
848 Shifting Letters string solution
849 Maximize Distance to Closest Person array solution
851 Loud and Rich depth-first-search solution
853 Car Fleet sort solution
855 Exam Room ordered-map solution
856 Score of Parentheses string stack solution
858 Mirror Reflection math solution
861 Score After Flipping Matrix greedy solution
863 All Nodes Distance K in Binary Tree tree depth-first-search breadth-first-search solution
865 Smallest Subtree with all the Deepest Nodes tree solution
866 Prime Palindrome math solution
869 Reordered Power of 2 math solution
86 Partition List linked-list two-pointers solution
870 Advantage Shuffle array greedy solution
873 Length of Longest Fibonacci Subsequence array dynamic-programming solution
875 Koko Eating Bananas binary-search solution
877 Stone Game math dynamic-programming minimax solution
880 Decoded String at Index stack solution
881 Boats to Save People two-pointers greedy solution
885 Spiral Matrix III math solution
886 Possible Bipartition depth-first-search graph solution
889 Construct Binary Tree from Preorder and Postorder Traversal tree solution
890 Find and Replace Pattern string solution
894 All Possible Full Binary Trees tree recursion solution
898 Bitwise ORs of Subarrays dynamic-programming bit-manipulation solution
89 Gray Code backtracking solution
8 String to Integer (atoi) math string solution
900 RLE Iterator array solution
901 Online Stock Span stack solution
904 Fruit Into Baskets two-pointers solution
907 Sum of Subarray Minimums array stack solution
909 Snakes and Ladders breadth-first-search solution
90 Subsets II array backtracking solution
910 Smallest Range II math greedy solution
911 Online Election binary-search solution
912 Sort an Array solution
915 Partition Array into Disjoint Intervals array solution
916 Word Subsets string solution
918 Maximum Sum Circular Subarray array solution
919 Complete Binary Tree Inserter tree solution
91 Decode Ways string dynamic-programming solution
921 Minimum Add to Make Parentheses Valid stack greedy solution
923 3Sum With Multiplicity two-pointers solution
926 Flip String to Monotone Increasing array solution
92 Reverse Linked List II linked-list solution
930 Binary Subarrays With Sum hash-table two-pointers solution
931 Minimum Falling Path Sum dynamic-programming solution
932 Beautiful Array divide-and-conquer solution
934 Shortest Bridge depth-first-search breadth-first-search solution
935 Knight Dialer dynamic-programming solution
939 Minimum Area Rectangle hash-table solution
93 Restore IP Addresses string backtracking solution
945 Minimum Increment to Make Array Unique array solution
946 Validate Stack Sequences stack solution
947 Most Stones Removed with Same Row or Column depth-first-search union-find solution
948 Bag of Tokens two-pointers greedy sort solution
949 Largest Time for Given Digits math solution
94 Binary Tree Inorder Traversal hash-table stack tree solution
950 Reveal Cards In Increasing Order array solution
951 Flip Equivalent Binary Trees tree solution
954 Array of Doubled Pairs array hash-table solution
955 Delete Columns to Make Sorted II greedy solution
957 Prison Cells After N Days hash-table solution
958 Check Completeness of a Binary Tree tree solution
959 Regions Cut By Slashes depth-first-search union-find graph solution
95 Unique Binary Search Trees II dynamic-programming tree solution
962 Maximum Width Ramp array solution
963 Minimum Area Rectangle II math geometry solution
966 Vowel Spellchecker hash-table string solution
967 Numbers With Same Consecutive Differences depth-first-search breadth-first-search solution
969 Pancake Sorting array sort solution
96 Unique Binary Search Trees dynamic-programming tree solution
971 Flip Binary Tree To Match Preorder Traversal tree depth-first-search solution
973 K Closest Points to Origin divide-and-conquer heap sort solution
974 Subarray Sums Divisible by K array hash-table solution
978 Longest Turbulent Subarray array dynamic-programming sliding-window solution
979 Distribute Coins in Binary Tree tree depth-first-search solution
981 Time Based Key-Value Store hash-table binary-search solution
983 Minimum Cost For Tickets dynamic-programming solution
984 String Without AAA or BBB greedy solution
986 Interval List Intersections two-pointers solution
987 Vertical Order Traversal of a Binary Tree hash-table tree solution
988 Smallest String Starting From Leaf tree depth-first-search solution
98 Validate Binary Search Tree tree depth-first-search solution
990 Satisfiability of Equality Equations union-find graph solution
991 Broken Calculator math greedy solution
994 Rotting Oranges breadth-first-search solution
998 Maximum Binary Tree II tree solution
Hard 119/330 36.06%
id 330 Hard Questions Tags 211 Solutions
440 K-th Smallest in Lexicographical Order
798 Smallest Rotation with Highest Score
154 Find Minimum in Rotated Sorted Array II array binary-search
644 Maximum Average Subarray II array binary-search
1157 Online Majority Element In Subarray array binary-search segment-tree
782 Transform to Chessboard array math
891 Sum of Subsequence Widths array math
1330 Reverse Subarray To Maximize Array Value array math
1499 Max Value of Equation array sliding-window
308 Range Sum Query 2D - Mutable binary-indexed-tree segment-tree
1649 Create Sorted Array through Instructions binary-indexed-tree segment-tree ordered-map
793 Preimage Size of Factorial Zeroes Function binary-search
1095 Find in Mountain Array binary-search
327 Count of Range Sum binary-search divide-and-conquer sort binary-indexed-tree segment-tree
1293 Shortest Path in a Grid with Obstacles Elimination breadth-first-search
1345 Jump Game IV breadth-first-search
913 Cat and Mouse breadth-first-search minimax
489 Robot Room Cleaner depth-first-search
749 Contain Virus depth-first-search
839 Similar String Groups depth-first-search union-find graph
928 Minimize Malware Spread II depth-first-search union-find graph
903 Valid Permutations for DI Sequence divide-and-conquer dynamic-programming
466 Count The Repetitions dynamic-programming
600 Non-negative Integers without Consecutive Ones dynamic-programming
629 K Inverse Pairs Array dynamic-programming
639 Decode Ways II dynamic-programming
656 Coin Path dynamic-programming
741 Cherry Pickup dynamic-programming
879 Profitable Schemes dynamic-programming
920 Number of Music Playlists dynamic-programming
940 Distinct Subsequences II dynamic-programming
943 Find the Shortest Superstring dynamic-programming
956 Tallest Billboard dynamic-programming
1000 Minimum Cost to Merge Stones dynamic-programming
1187 Make Array Strictly Increasing dynamic-programming
1246 Palindrome Removal dynamic-programming
1269 Number of Ways to Stay in the Same Place After Some Steps dynamic-programming
1301 Number of Paths with Max Score dynamic-programming
1349 Maximum Students Taking Exam dynamic-programming
1388 Pizza With 3n Slices dynamic-programming
1397 Find All Good Strings dynamic-programming
1416 Restore The Array dynamic-programming
1425 Constrained Subsequence Sum dynamic-programming
1458 Max Dot Product of Two Subsequences dynamic-programming
1483 Kth Ancestor of a Tree Node dynamic-programming
1601 Maximum Number of Achievable Transfer Requests dynamic-programming
1639 Number of Ways to Form a Target String Given a Dictionary dynamic-programming
691 Stickers to Spell Word dynamic-programming backtracking
1655 Distribute Repeating Integers dynamic-programming backtracking
1373 Maximum Sum BST in Binary Tree dynamic-programming binary-search-tree
1125 Smallest Sufficient Team dynamic-programming bit-manipulation
1434 Number of Ways to Wear Different Hats to Each Other dynamic-programming bit-manipulation
664 Strange Printer dynamic-programming depth-first-search
975 Odd Even Jump dynamic-programming stack ordered-map
968 Binary Tree Cameras dynamic-programming tree depth-first-search
587 Erect the Fence geometry
1453 Maximum Number of Darts Inside of a Circular Dartboard geometry
1153 String Transforms Into Another String graph
1494 Parallel Courses II graph
757 Set Intersection Size At Least Two greedy
1354 Construct Target Array With Multiple Sums greedy
1505 Minimum Possible Integer After at Most K Adjacent Swaps On Digits greedy
1591 Strange Printer II greedy
995 Minimum Number of K Consecutive Bit Flips greedy sliding-window
1632 Rank Transform of a Matrix greedy union-find
1001 Grid Illumination hash-table
1224 Maximum Equal Frequency hash-table
710 Random Pick with Blacklist hash-table binary-search sort random
1178 Number of Valid Words for Each Puzzle hash-table bit-manipulation
711 Number of Distinct Islands II hash-table depth-first-search
857 Minimum Cost to Hire K Workers heap
882 Reachable Nodes In Subdivided Graph heap
864 Shortest Path to Get All Keys heap breadth-first-search
759 Employee Free Time heap greedy
335 Self Crossing math
805 Split Array With Same Average math
810 Chalkboard XOR Game math
906 Super Palindromes math
972 Equal Rational Numbers math
1088 Confusing Number II math backtracking
1307 Verbal Arithmetic Puzzle math backtracking
1467 Probability of a Two Boxes Having The Same Number of Distinct Balls math backtracking
996 Number of Squareful Arrays math backtracking graph
483 Smallest Good Base math binary-search
878 Nth Magical Number math binary-search
887 Super Egg Drop math binary-search dynamic-programming
927 Three Equal Parts math binary-search greedy
1622 Fancy Sequence math design
902 Numbers At Most N Given Digit Set math dynamic-programming
964 Least Operators to Express Number math dynamic-programming
1012 Numbers With Repeated Digits math dynamic-programming
1067 Digit Count in Range math dynamic-programming
1199 Minimum Time to Build Blocks math dynamic-programming
1363 Largest Multiple of Three math dynamic-programming
952 Largest Component Size by Common Factor math union-find
843 Guess the Word minimax
1606 Find Servers That Handled Most Number of Requests ordered-map
850 Rectangle Area II segment-tree line-sweep
699 Falling Squares segment-tree ordered-map
715 Range Module segment-tree ordered-map
158 Read N Characters Given Read4 II - Call multiple times string
736 Parse Lisp Expression string
1392 Longest Happy Prefix string
730 Count Different Palindromic Subsequences string dynamic-programming
1449 Form Largest Integer With Digits That Add up to Target string dynamic-programming
1531 String Compression II string dynamic-programming
936 Stamping The Sequence string greedy
1316 Distinct Echo Substrings string rolling-hash
591 Tag Validator string stack
1163 Last Substring in Lexicographical Order string suffix-array
1597 Build Binary Expression Tree From Infix Expression string tree
428 Serialize and Deserialize N-ary Tree tree
431 Encode N-ary Tree to Binary Tree tree
1516 Move Sub-Tree of N-Ary Tree tree
834 Sum of Distances in Tree tree depth-first-search
685 Redundant Connection II tree depth-first-search union-find graph
745 Prefix and Suffix Search trie
1610 Maximum Number of Visible Points two-pointers geometry
803 Bricks Falling When Hit union-find
1028 Recover a Tree From Preorder Traversal tree depth-first-search solution
1032 Stream of Characters trie solution
1036 Escape a Large Maze breadth-first-search solution
1044 Longest Duplicate Substring hash-table binary-search solution
1063 Number of Valid Subarrays stack solution
1074 Number of Submatrices That Sum to Target array dynamic-programming sliding-window solution
1092 Shortest Common Supersequence dynamic-programming solution
1096 Brace Expansion II string solution
10 Regular Expression Matching string dynamic-programming backtracking solution
1106 Parsing A Boolean Expression string solution
1121 Divide Array Into Increasing Sequences math solution
1136 Parallel Courses dynamic-programming depth-first-search graph solution
1147 Longest Chunked Palindrome Decomposition dynamic-programming rolling-hash solution
115 Distinct Subsequences string dynamic-programming solution
1168 Optimize Water Distribution in a Village union-find graph solution
1172 Dinner Plate Stacks design solution
1183 Maximum Number of Ones math sort solution
1192 Critical Connections in a Network depth-first-search solution
1203 Sort Items by Groups Respecting Dependencies depth-first-search graph topological-sort solution
1206 Design Skiplist design solution
1210 Minimum Moves to Reach Target with Rotations breadth-first-search solution
1216 Valid Palindrome III string dynamic-programming solution
1220 Count Vowels Permutation dynamic-programming solution
1231 Divide Chocolate binary-search greedy solution
1235 Maximum Profit in Job Scheduling binary-search dynamic-programming sort solution
123 Best Time to Buy and Sell Stock III array dynamic-programming solution
1240 Tiling a Rectangle with the Fewest Squares dynamic-programming backtracking solution
124 Binary Tree Maximum Path Sum tree depth-first-search solution
1250 Check If It Is a Good Array math solution
1255 Maximum Score Words Formed by Letters bit-manipulation solution
1259 Handshakes That Don't Cross math dynamic-programming solution
1263 Minimum Moves to Move a Box to Their Target Location breadth-first-search solution
126 Word Ladder II array string backtracking breadth-first-search solution
1274 Number of Ships in a Rectangle divide-and-conquer solution
1278 Palindrome Partitioning III dynamic-programming solution
1284 Minimum Number of Flips to Convert Binary Matrix to Zero Matrix breadth-first-search solution
1289 Minimum Falling Path Sum II dynamic-programming solution
128 Longest Consecutive Sequence array union-find solution
1298 Maximum Candies You Can Get from Boxes breadth-first-search solution
1312 Minimum Insertion Steps to Make a String Palindrome dynamic-programming solution
1320 Minimum Distance to Type a Word Using Two Fingers dynamic-programming solution
1326 Minimum Number of Taps to Open to Water a Garden dynamic-programming greedy solution
132 Palindrome Partitioning II dynamic-programming solution
1335 Minimum Difficulty of a Job Schedule dynamic-programming solution
1340 Jump Game V dynamic-programming solution
1359 Count All Valid Pickup and Delivery Options math dynamic-programming solution
135 Candy greedy solution
1368 Minimum Cost to Make at Least One Valid Path in a Grid breadth-first-search solution
1377 Frog Position After T Seconds depth-first-search solution
1383 Maximum Performance of a Team greedy sort solution
1402 Reducing Dishes dynamic-programming solution
1406 Stone Game III dynamic-programming solution
140 Word Break II dynamic-programming backtracking solution
1411 Number of Ways to Paint N × 3 Grid dynamic-programming solution
1420 Build Array Where You Can Find The Maximum Exactly K Comparisons dynamic-programming solution
1439 Find the Kth Smallest Sum of a Matrix With Sorted Rows heap solution
1444 Number of Ways of Cutting a Pizza dynamic-programming solution
1463 Cherry Pickup II dynamic-programming solution
1473 Paint House III dynamic-programming solution
1478 Allocate Mailboxes math dynamic-programming solution
1489 Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree depth-first-search union-find solution
149 Max Points on a Line hash-table math solution
1510 Stone Game IV dynamic-programming solution
1515 Best Position for a Service Centre geometry solution
1520 Maximum Number of Non-Overlapping Substrings greedy solution
1521 Find a Value of a Mysterious Function Closest to Target binary-search bit-manipulation segment-tree solution
1526 Minimum Number of Increments on Subarrays to Form a Target Array segment-tree solution
1537 Get the Maximum Score dynamic-programming solution
1542 Find Longest Awesome Substring string bit-manipulation solution
1547 Minimum Cost to Cut a Stick dynamic-programming solution
1548 The Most Similar Path in a Graph dynamic-programming graph solution
1553 Minimum Number of Days to Eat N Oranges dynamic-programming solution
1559 Detect Cycles in 2D Grid depth-first-search solution
1563 Stone Game V dynamic-programming solution
1568 Minimum Number of Days to Disconnect Island greedy solution
1569 Number of Ways to Reorder Array to Get Same BST dynamic-programming solution
1575 Count All Possible Routes dynamic-programming solution
1579 Remove Max Number of Edges to Keep Graph Fully Traversable union-find solution
1585 Check If String Is Transformable With Substring Sort Operations string greedy solution
1595 Minimum Cost to Connect Two Groups of Points dynamic-programming graph solution
1611 Minimum One Bit Operations to Make Integers Zero dynamic-programming bit-manipulation solution
1617 Count Subtrees With Max Distance Between Cities backtracking solution
1627 Graph Connectivity With Threshold math union-find solution
1643 Kth Smallest Instructions dynamic-programming solution
164 Maximum Gap sort solution
1659 Maximize Grid Happiness dynamic-programming backtracking solution
174 Dungeon Game binary-search dynamic-programming solution
188 Best Time to Buy and Sell Stock IV dynamic-programming solution
212 Word Search II backtracking trie solution
214 Shortest Palindrome string solution
218 The Skyline Problem divide-and-conquer heap binary-indexed-tree segment-tree line-sweep solution
224 Basic Calculator math stack solution
233 Number of Digit One math solution
239 Sliding Window Maximum heap sliding-window solution
23 Merge k Sorted Lists linked-list divide-and-conquer heap solution
248 Strobogrammatic Number III math recursion solution
25 Reverse Nodes in k-Group linked-list solution
265 Paint House II dynamic-programming solution
269 Alien Dictionary graph topological-sort solution
272 Closest Binary Search Tree Value II stack tree solution
273 Integer to English Words math string solution
282 Expression Add Operators divide-and-conquer solution
291 Word Pattern II backtracking solution
295 Find Median from Data Stream heap design solution
296 Best Meeting Point math sort solution
297 Serialize and Deserialize Binary Tree tree design solution
301 Remove Invalid Parentheses depth-first-search breadth-first-search solution
302 Smallest Rectangle Enclosing Black Pixels binary-search solution
305 Number of Islands II union-find solution
30 Substring with Concatenation of All Words hash-table two-pointers string solution
312 Burst Balloons divide-and-conquer dynamic-programming solution
315 Count of Smaller Numbers After Self binary-search divide-and-conquer sort binary-indexed-tree segment-tree solution
317 Shortest Distance from All Buildings breadth-first-search solution
321 Create Maximum Number dynamic-programming greedy solution
329 Longest Increasing Path in a Matrix depth-first-search topological-sort memoization solution
32 Longest Valid Parentheses string dynamic-programming solution
330 Patching Array greedy solution
336 Palindrome Pairs hash-table string trie solution
340 Longest Substring with At Most K Distinct Characters hash-table string sliding-window solution
352 Data Stream as Disjoint Intervals binary-search ordered-map solution
354 Russian Doll Envelopes binary-search dynamic-programming solution
358 Rearrange String k Distance Apart hash-table heap greedy solution
363 Max Sum of Rectangle No Larger Than K binary-search dynamic-programming queue solution
37 Sudoku Solver hash-table backtracking solution
381 Insert Delete GetRandom O(1) - Duplicates allowed array hash-table design solution
391 Perfect Rectangle line-sweep solution
403 Frog Jump dynamic-programming solution
407 Trapping Rain Water II heap breadth-first-search solution
410 Split Array Largest Sum binary-search dynamic-programming solution
411 Minimum Unique Word Abbreviation backtracking bit-manipulation solution
41 First Missing Positive array solution
420 Strong Password Checker solution
425 Word Squares backtracking trie solution
42 Trapping Rain Water array two-pointers stack solution
432 All O`one Data Structure design solution
446 Arithmetic Slices II - Subsequence dynamic-programming solution
44 Wildcard Matching string dynamic-programming backtracking greedy solution
458 Poor Pigs math solution
45 Jump Game II array greedy solution
460 LFU Cache design solution
465 Optimal Account Balancing solution
471 Encode String with Shortest Length dynamic-programming solution
472 Concatenated Words dynamic-programming depth-first-search trie solution
479 Largest Palindrome Product solution
480 Sliding Window Median sliding-window solution
488 Zuma Game depth-first-search solution
493 Reverse Pairs binary-search divide-and-conquer sort binary-indexed-tree segment-tree solution
499 The Maze III depth-first-search breadth-first-search solution
4 Median of Two Sorted Arrays array binary-search divide-and-conquer solution
502 IPO heap greedy solution
514 Freedom Trail divide-and-conquer dynamic-programming depth-first-search solution
517 Super Washing Machines math dynamic-programming solution
51 N-Queens backtracking solution
527 Word Abbreviation string sort solution
52 N-Queens II backtracking solution
546 Remove Boxes dynamic-programming depth-first-search solution
552 Student Attendance Record II dynamic-programming solution
564 Find the Closest Palindrome string solution
568 Maximum Vacation Days dynamic-programming solution
588 Design In-Memory File System design solution
60 Permutation Sequence math backtracking solution
630 Course Schedule III greedy solution
631 Design Excel Sum Formula design solution
632 Smallest Range Covering Elements from K Lists hash-table two-pointers string solution
642 Design Search Autocomplete System design trie solution
65 Valid Number math string solution
660 Remove 9 math solution
668 Kth Smallest Number in Multiplication Table binary-search solution
675 Cut Off Trees for Golf Event breadth-first-search solution
679 24 Game depth-first-search solution
683 K Empty Slots ordered-map solution
689 Maximum Sum of 3 Non-Overlapping Subarrays array dynamic-programming solution
68 Text Justification string solution
719 Find K-th Smallest Pair Distance array binary-search heap solution
726 Number of Atoms hash-table stack recursion solution
727 Minimum Window Subsequence dynamic-programming sliding-window solution
72 Edit Distance string dynamic-programming solution
732 My Calendar III segment-tree ordered-map solution
753 Cracking the Safe math depth-first-search solution
761 Special Binary String string recursion solution
765 Couples Holding Hands greedy union-find graph solution
768 Max Chunks To Make Sorted II array solution
76 Minimum Window Substring hash-table two-pointers string sliding-window solution
770 Basic Calculator IV hash-table string stack solution
772 Basic Calculator III string stack solution
773 Sliding Puzzle breadth-first-search solution
774 Minimize Max Distance to Gas Station binary-search solution
778 Swim in Rising Water binary-search heap depth-first-search union-find solution
780 Reaching Points math solution
786 K-th Smallest Prime Fraction binary-search heap solution
815 Bus Routes breadth-first-search solution
818 Race Car dynamic-programming heap solution
827 Making A Large Island depth-first-search solution
828 Count Unique Characters of All Substrings of a Given String two-pointers solution
829 Consecutive Numbers Sum math solution
847 Shortest Path Visiting All Nodes dynamic-programming breadth-first-search solution
84 Largest Rectangle in Histogram array stack solution
854 K-Similar Strings breadth-first-search graph solution
85 Maximal Rectangle array hash-table dynamic-programming stack solution
862 Shortest Subarray with Sum at Least K binary-search queue solution
871 Minimum Number of Refueling Stops dynamic-programming heap solution
87 Scramble String string dynamic-programming solution
895 Maximum Frequency Stack hash-table stack solution
899 Orderly Queue math string solution
924 Minimize Malware Spread depth-first-search union-find solution
960 Delete Columns to Make Sorted III dynamic-programming solution
97 Interleaving String string dynamic-programming solution
980 Unique Paths III backtracking depth-first-search solution
982 Triples with Bitwise AND Equal To Zero dynamic-programming solution
992 Subarrays with K Different Integers hash-table two-pointers sliding-window solution
99 Recover Binary Search Tree tree depth-first-search solution

Dependencies

~0.8–1.2MB
~17K SLoC