README ¶ leetcode Archive of leetcode solutions. # Title Solution Difficulty 1 Two Sum Javascript, Go Easy 2 Add Two Numbers Typescript, Go Medium 3 Longest Substring Without Repeating Characters Typescript, Go Medium 4 Median of Two Sorted Arrays Typescript Hard 6 Zigzag Conversion Go Medium 8 String to Integer (atoi) Typescript Medium 9 Palindrome Number Typescript, Go Easy 11 Container With Most Water Typescript, Go Medium 12 Integer to Roman Typescript, Go Medium 13 Roman to Integer Typescript, Go Easy 14 Longest Common Prefix Typescript Easy 15 3Sum Typescript Medium 17 Letter Combinations of a Phone Number Go Medium 19 Remove Nth Node From End of List Go Medium 20 Valid Parentheses Typescript, Go Easy 21 Merge Two Sorted Lists Typescript, Go Easy 22 Generate Parentheses Typescript Medium 25 Reverse Nodes in k-Group Go Hard 26 Remove Duplicates from Sorted Array Typescript, Go Easy 27 Remove Element Typescript, Go Easy 28 Find the Index of the First Occurrence in a String Go Easy 29 Divide Two Integers Typescript Medium 35 Search Insert Position Go Easy 36 Valid Sudoku Typescript Medium 37 Sudoku Solver Typescript Hard 39 Combination Sum Go Medium 42 Trapping Rain Water Go Hard 45 Jump Game 2 Go Medium 46 Permutations Python Medium 48 Rotate Image Go Medium 49 Group Anagrams Typescript, Go Medium 54 Spiral Matrix Go Medium 55 Jump Game Go Medium 56 Merge Intervals Go Medium 57 Insert Intervals Go Medium 58 Length of Last Word Go Easy 61 Rotate List Go Medium 62 Unique Paths Go Medium 66 Plus One Go Easy 67 Add Binary Go Easy 68 Text Justification Go Hard 69 Sqrt(x) Go Easy 70 Climbing Stairs Go Easy 71 Simplify Path Go Medium 72 Edit Distance Go Medium 73 Set Matrix Zeroes Go Medium 74 Search a 2D Matrix Typescript Medium 75 Sort Colors Typescript Medium 76 Minimum Window Substring Go Hard 77 Combinations Go Medium 80 Remove Duplicates from Sorted Array II Go Medium 82 Remove Duplicates from Sorted List II Go Medium 86 Partition List Go Medium 88 Merge Sorted Array Typescript, Go Easy 92 Reverse Linked List II Go Medium 98 Validate Binary Search Tree Go Medium 100 Same Tree Typescript, Go Easy 101 Symmetric Tree Go Easy 102 Binary Tree Level Order Traversal Typescript, Go Medium 103 Binary Tree Zigzag Level Order Traversal Go Medium 104 Maximum Depth of Binary Tree Typescript, Go Easy 105 Construct Binary Tree from Preorder and Inorder Traversal Go Medium 106 Construct Binary Tree from Inorder and Postorder Traversal Go Medium 108 Convert Sorted Array to Binary Search Tree Go Easy 112 Path Sum Go Easy 114 Flatten Binary Tree to Linked List Go Medium 117 Populating Next Right Pointers in Each Node II Go Medium 121 Best Time to Buy and Sell Stock Typescript, Go Easy 122 Best Time to Buy and Sell Stock II Go Medium 124 Binary Tree Maximum Path Sum Go Har 125 Valid Palindrome Typescript, Go Easy 127 Word Ladder Go Hard 128 Longest Consecutive Sequence Go Medium 129 Sum Root to Leaf Numbers Go Medium 130 Surrounded Regions Go Medium 133 Clone Graph Go Medium 134 Gas Station Go Medium 135 Candy Go Hard 136 Single Number Go Easy 138 Copy List with Random Pointer Go Medium 141 Linked List Cycle Typescript, Go Easy 146 LRU Cache Go Medium 148 Sort List Go Medium 150 Evaluate Reverse Polish Notation Go Medium 151 Reverse Words in a String Go Medium 155 Min Stack Typescript, Go Medium 162 Find Peak Element Go Medium 167 Two Sum II - Input Array Is Sorted Typescript, Go Medium 169 Majority Element Typescript Easy 173 Binary Search Tree Iterator Go Medium 187 Repeated DNA Sequences Go Medium 189 Rotate Array Go Medium 190 Reverse Bits Go Easy 191 Number of 1 Bits Go Easy 199 House Robber Go Medium 199 Binary Tree Right Side View Go Medium 200 Number of Islands Go Medium 202 Happy Number Go Easy 205 Isomorphic Strings Go Easy 206 Reverse Linked List Typescript, Go Medium 207 Course Schedule Go Medium 208 Implement Trie (Prefix Tree) Go Medium 209 Minimum Size Subarray Sum Go Medium 210 Course Schedule II Go Medium 211 Design Add and Search Words Data Structure Go Medium 212 Word Search II Go Hard 215 Kth Largest Element in an Array Typescript Medium 216 Combination Sum III Go Medium 217 Contains Duplicate Typescript, Go Easy 219 Contains Duplicate II Typescript, Go Easy 222 Count Complete Tree Nodes Go Easy 224 Basic Calculator Go Hard 225 Implement Stack using Queues Go Easy 226 Invert Binary Tree Typescript, Go Easy 228 Summary Ranges Go Easy 230 Kth Smallest Element in a BST Go Medium 235 Lowest Common Ancestor of a Binary Search Tree Typescript Medium 236 Lowest Common Ancestor of a Binary Tree Go Medium 238 Product of Array Except Self Go Medium 242 Valid Anagram Typescript, Go Easy 268 Missing Number Go Easy 274 H-Index Go Medium 283 Move Zeroes Go Easy 289 Game of Life Go Medium 290 Word Pattern Go Easy 304 Range Sum Query 2D - Immutable Typescript Medium 328 Odd Even Linked List Go Medium 334 Increasing Triplet Subsequence Go Medium 338 Counting Bits Go Easy 344 Reverse String Typescript Easy 347 Top K Frequent Elements Typescript Medium 371 Sum of Two Integers Go Medium 374 Guess Number Higher or Lower Go Easy 375 Reverse Vowels of a String Go Easy 380 Insert Delete GetRandom O(1) Go Medium 383 Ransom note Typescript, Go Easy 392 Is Subsequence Go Easy 394 Decode String Go Medium 399 Evaluate Division Go Medium 409 Longest Palindrome Typescript Easy 412 Fizz Buzz Go Easy 424 Longest Repeating Character Replacement Go Medium 433 Minimum Genetic Mutation Go Medium 435 Non-overlapping Intervals Go Medium 437 Path Sum III Go Medium 443 String Compression Go Medium 450 Delete Node in a BST Go Medium 452 Minimum Number of Arrows to Burst Balloons Go Medium 474 Ones and Zeroes Go Medium 485 Max Consecutive Ones Go Easy 530 Minimum Absolute Difference in BST Go Easy 547 Number of Provinces Go Medium 567 Permutation in String Typescript Medium 572 Subtree of Another Tree Typescript Easy 594 Longest Harmonious Subsequence Go Easy 605 Can Place Flowers Go Easy 637 Average of Levels in Binary Tree Go Easy 643 Maximum Average Subarray I Go Easy 645 Set Mismatch Go Easy 649 Dota2 Senate Go Medium 682 Baseball Game Typescript Easy 700 Search in a Binary Search Tree Go Easy 704 Binary Search Go Easy 705 Design HashSet Typescript Easy 706 Design HashMap Typescript Easy 714 Best Time to Buy and Sell Stock with Transaction Fee Go Medium 717 1-bit and 2-bit Characters Go Easy 724 Find Pivot Index Go Easy 735 Asteroid Collision Go Medium 739 Daily Temperatures Go Medium 746 Min Cost Climbing Stairs Go Easy 757 Set Intersection Size At Least Two Go Hard 790 Domino and Tromino Tiling Go Medium 841 Keys and Rooms Go Medium 872 Leaf-Similar Trees Go Easy 875 Koko Eating Bananas Typescript Medium 901 Online Stock Span Go Medium 909 Snakes and Ladders Go Medium 912 Sort an Array Typescript Medium 933 Number of Recent Calls Go Easy 994 Rotting Oranges Go Medium 1004 Max Consecutive Ones III Go Medium 1015 Smallest Integer Divisible by K Go Medium 1071 Greatest Common Divisor of Strings Go Easy 1072 Flip Columns For Maximum Number of Equal Rows Go Medium 1018 Binary Prefix Divisible By 5 Go Easy 1137 N-th Tribonacci Number Go Easy 1143 Longest Common Subsequence Go Medium 1161 Maximum Level Sum of a Binary Tree Go Medium 1207 Unique Number of Occurrences Go Medium 1268 Search Suggestions System Go Medium 1304 Find N Unique Integers Sum up to Zero Typescript Easy 1318 Minimum Flips to Make a OR b Equal to c Go Medium 1342 Number of Steps to Reduce a Number to Zero Go Easy 1372 Longest ZigZag Path in a Binary Tree Go Medium 1431 Kids With the Greatest Number of Candies Go Easy 1437 Check If All 1's Are at Least Length K Places Away Go Easy 1448 Count Good Nodes in Binary Tree Go Medium 1456 Maximum Number of Vowels in a Substring of Given Length Go Medium 1466 Reorder Routes to Make All Paths Lead to the City Zero C++ Medium 1470 Shuffle the Array Go Easy 1480 Running Sum of 1d Array Go Easy 1493 Longest Subarray of 1's After Deleting One Element Go Medium 1513 Number of Substrings With Only 1s Go Medium 1652 Defuse the Bomb Go Easy 1657 Determine if Two Strings Are Close Go Medium 1672 Richest Customer Wealth Go Easy 1679 Max Number of K-Sum Pairs Go Medium 1732 Find the Highest Altitude Go Easy 1763 Longest Nice Substring Go Easy 1768 Merge Strings Alternately Typescript, Go Easy 1792 Maximum Average Pass Ratio Typescript Medium 1863 Sum of All Subset XOR Totals Go Easy 1876 Substrings of Size Three with Distinct Characters Go Easy 1926 Nearest Exit from Entrance in Maze Go Medium 1930 Unique Length-3 Palindromic Subsequences Go Medium 1929 Concatenation of Array Typescript, Go Easy 1984 Minimum Difference Between Highest and Lowest of K Scores Go Easy 2095 Delete the Middle Node of a Linked List Go Medium 2130 Maximum Twin Sum of a Linked List Go Medium 2154 Keep Multiplying Found Values by Two Go Easy 2169 Count Operations to Obtain Zero Go, C++ Easy 2215 Find the Difference of Two Arrays Go Easy 2257 Count Unguarded Cells in the Grid Go Medium 2269 Find the K-Beauty of a Number Go Easy 2300 Successful Pairs of Spells and Potions Go Medium 2336 Smallest Number in Infinite Set Go Medium 2352 Equal Row and Column Pairs Go Medium 2379 Minimum Recolors to Get K Consecutive Black Blocks Go Easy 2390 Removing Stars From a String Go Medium 2435 Paths in Matrix Whose Sum Is Divisible by K Go Hard 2461 Maximum Sum of Distinct Subarrays With Length K Go Medium 2462 Total Cost to Hire K Workers Go Medium 2542 Maximum Subsequence Score Go Medium 2536 Increment Submatrices by One Go Medium 2620 Counter Javascript Easy 2621 Sleep Javascript Easy 2654 Minimum Number of Operations to Make All Array Elements Equal to 1 Go Medium 2703 Return Length of Arguments Passed Javascript Easy 2760 Longest Even Odd Subarray With Threshold Go Easy 2749 Minimum Operations to Make the Integer Zero Typescript Medium 2932 Maximum Strong Pair XOR I Go Easy 3025 Find the Number of Ways to Place People I Typescript Medium 3027 Find the Number of Ways to Place People II Typescript Hard 3190 Find Minimum Operations to Make All Elements Divisible by Three Go Easy 3228 Maximum Number of Operations to Move Ones to the End Go Medium 3234 Count the Number of Substrings With Dominant Ones Go Medium 3318 Find X-Sum of All K-Long Subarrays I Go Easy 3381 Maximum Subarray Sum With Length Divisible by K Go Medium 3516 Find Closest Person Typescript Easy 3542 Minimum Operations to Convert All Elements to Zero Go Medium Expand ▾ Collapse ▴ Directories ¶ Show internal Expand all Path Synopsis algorithms 1-bit-and-2-bit-characters command 3sum command add-binary command add-two-numbers command asteroid-collision command average-of-levels-in-binary-tree command basic-calculator command best-time-to-buy-and-sell-stock command best-time-to-buy-and-sell-stock-ii command best-time-to-buy-and-sell-stock-with-transaction-fee command binary-prefix-divisible-by-5 command binary-search command binary-search-tree-iterator command binary-tree-level-order-traversal command binary-tree-maximum-path-sum command binary-tree-right-side-view command binary-tree-zigzag-level-order-traversal command can-place-flowers command candy command check-if-all-1s-are-at-least-length-k-places-away command climbing-stairs command clone-graph command combination-sum command combination-sum-iii command combinations command concatenation-of-array command construct-binary-tree-from-inorder-and-postorder-traversal command construct-binary-tree-from-preorder-and-inorder-traversal command container-with-most-water command contains-duplicate command contains-duplicate-ii command convert-sorted-array-to-binary-search-tree command copy-list-with-random-pointer command count-complete-tree-nodes command count-good-nodes-in-binary-tree command count-operations-to-obtain-zero command count-the-number-of-substrings-with-dominant-ones command count-unguarded-cells-in-the-grid command counting-bits command course-schedule command course-schedule-II command daily-temperatures command decode-string command defuse-the-bomb command delete-node-in-a-bst command delete-the-middle-node-of-a-linked-list command design-add-and-search-words-data-structure command determine-if-two-strings-are-close command domino-and-tromino-tiling command dota2-senate command edit-distance command equal-row-and-column-pairs command evaluate-division command evaluate-reverse-polish-notation command find-minimum-operations-to-make-all-elements-divisible-by-three command find-peak-element command find-pivot-index command find-the-difference-of-two-arrays command find-the-highest-altitude command find-the-index-of-the-first-occurrence-in-a-string command find-the-k-beauty-of-a-number command find-x-sum-of-all-k-long-subarrays-i command fizz-buzz command flatten-binary-tree-to-linked-list command flip-columns-for-maximum-number-of-equal-rows command game-of-life command gas-station command greatest-common-divisor-of-strings command group-anagrams command guess-number-higher-or-lower command h-index command happy-number command house-robber command implement-stack-using-queues command implement-trie-prefix-tree command increasing-triplet-subsequence command increment-submatrices-by-one command insert-delete-getrandom-o1 command insert-interval command integer-to-roman command invert-binary-tree command is-subsequence command isomorphic-strings command jump-game command jump-game-ii command keep-multiplying-found-values-by-two command keys-and-rooms command kids-with-the-greatest-number-of-candies command kth-smallest-element-in-a-bst command leaf-similar-trees command length-of-last-word command letter-combinations-of-a-phone-number command linked-list-cycle command longest-common-prefix command longest-common-subsequence command longest-consecutive-sequence command longest-even-odd-subarray-with-threshold command longest-harmonious-subsequence command longest-nice-substring command longest-repeating-character-replacement command longest-subarray-of-1s-after-deleting-one-element command longest-substring-without-repeating-characters command longest-zigzag-path-in-a-binary-tree command lowest-common-ancestor-of-a-binary-tree command lru-cache command majority-element command max-consecutive-ones command max-consecutive-ones-iii command max-number-of-k-sum-pairs command maximum-average-subarray-i command maximum-depth-of-binary-tree command maximum-level-sum-of-a-binary-tree command maximum-number-of-operations-to-move-ones-to-the-end command maximum-number-of-vowels-in-a-substring-of-given-length command maximum-strong-pair-xor-i command maximum-subarray-sum-with-length-divisible-by-k command maximum-subsequence-score command maximum-sum-of-distinct-subarrays-with-length-k command maximum-twin-sum-of-a-linked-list command merge-intervals command merge-sorted-array command merge-strings-alternately command merge-two-sorted-lists command min-cost-climbing-stairs command min-stack command minimum-absolute-difference-in-bst command minimum-difference-between-highest-and-lowest-of-k-scores command minimum-flips-to-make-a-or-b-equal-to-c command minimum-genetic-mutation command minimum-number-of-arrows-to-burst-balloons command minimum-number-of-operations-to-make-all-array-elements-equal-to-1 command minimum-operations-to-convert-all-elements-to-zero command minimum-recolors-to-get-k-consecutive-black-blocks command minimum-size-subarray-sum command minimum-window-substring command missing-number command move-zeroes command n-th-tribonacci-number command nearest-exit-from-entrance-in-maze command non-overlapping-intervals command number-of-1-bits command number-of-islands command number-of-provinces command number-of-recent-calls command number-of-steps-to-reduce-a-number-to-zero command number-of-substrings-with-only-1s command odd-even-linked-list command ones-and-zeroes command online-stock-span command palindrome-number command partition-list command path-sum command path-sum-iii command paths-in-matrix-whose-sum-is-divisible-by-k command plus-one command populating-next-right-pointers-in-each-node-ii command product-of-array-except-self command ransom-note command remove-duplicates-from-sorted-array command remove-duplicates-from-sorted-array-ii command remove-duplicates-from-sorted-list-ii command remove-element command remove-nth-node-from-end-of-list command removing-stars-from-a-string command repeated-dna-sequences command reverse-bits command reverse-linked-list command reverse-linked-list-ii command reverse-nodes-in-k-group command reverse-vowels-of-a-string command reverse-words-in-a-string command richest-customer-wealth command roman-to-integer command rotate-array command rotate-image command rotate-list command rotting-oranges command same-tree command search-in-a-binary-search-tree command search-insert-position command search-suggestions-system command set-intersection-size-at-least-two command set-matrix-zeroes command set-mismatch command shuffle-the-array command simplify-path command single-number command smallest-integer-divisible-by-k command smallest-number-in-infinite-set command snakes-and-ladders command sort-list command spiral-matrix command sqrtx command string-compression command substring-with-concatenation-of-all-words command substrings-of-size-three-with-distinct-characters command successful-pairs-of-spells-and-potions command sum-of-all-subset-xor-totals command sum-of-two-integers command sum-root-to-leaf-numbers command summary-ranges command surrounded-regions command symmetric-tree command text-justification command total-cost-to-hire-k-workers command trapping-rain-water command two-sum-ii command unique-length-3-palindromic-subsequences command unique-number-of-occurrences command unique-paths command valid-anagram command valid-palindrome command valid-parentheses command valid-sudoku command validate-binary-search-tree command word-ladder command word-pattern command word-search-ii command zigzag-conversion command Click to show internal directories. Click to hide internal directories.