Leetcode Solutions Index
Tags: algorithms, javascript, java, python
Published: 2021-02-02 19:21:39

This is the master index for my series of [Leetcode](https://leetcode.com/problemset/all/) solution explanations. If you like these solutions or found them useful, please like this post.

---

###Hard Problem Solutions:
|**#**|**TITLE**|**RELATED TOPICS**|
|---|---|---|
32|[Longest Valid Parentheses](https://dev.to/seanpgallivan/solution-longest-valid-parentheses-592n)|Stack
51|[N-Queens](https://dev.to/seanpgallivan/solution-n-queens-5hdb)|Backtracking, DFS, Recursion, Bit Manipulation
52|[N-Queens II](https://dev.to/seanpgallivan/solution-n-queens-ii-f08)|Backtracking, DFS, Recursion, Bit Manipulation
65|[Valid Number](https://dev.to/seanpgallivan/solution-valid-number-3gf5)|String
164|[Maximum Gap](https://dev.to/seanpgallivan/solution-maximum-gap-212k)|Bucket Sort, Math
329|[Longest Increasing Path in a Matrix](https://dev.to/seanpgallivan/solution-longest-increasing-path-in-a-matrix-4o5f)|Recursion, DFS, Memoization
336|[Palindrome Pairs](https://dev.to/seanpgallivan/solution-palindrome-pairs-23j6)|Map
354|[Russian Doll Envelopes](https://dev.to/seanpgallivan/solution-russian-doll-envelopes-459i)|LIS, Binary Search, DP
630|[Course Schedule III](https://dev.to/seanpgallivan/solution-course-schedule-iii-48hn)|Priority Queue, Heap
745|[Prefix and Suffix Search](https://dev.to/seanpgallivan/solution-prefix-and-suffix-search-11m5)|Trie
778|[Swim in Rising Water](https://dev.to/seanpgallivan/solution-swim-in-rising-water-4gfe)|Dijkstra's, Priority Queue, Heap
871|[Minimum Number of Refueling Stops](https://dev.to/seanpgallivan/solution-minimum-number-of-refueling-stops-11f1)|Max Priority Queue, Max Heap, Greedy
895|[Maximum Frequency Stack](https://dev.to/seanpgallivan/solution-maximum-frequency-stack-2155)|Frequency Map, Stack
906|[Super Palindromes](https://dev.to/seanpgallivan/solution-super-palindromes-30d)|Math, Palindromes
936|[Stamping The Sequence](https://dev.to/seanpgallivan/solution-stamping-the-sequence-4fc7)|Character Mask
968|[Binary Tree Cameras](https://dev.to/seanpgallivan/solution-binary-tree-cameras-1a5i)|DFS, Recursion
987|[Vertical Order Traversal of a Binary Tree](https://dev.to/seanpgallivan/solution-vertical-order-traversal-of-a-binary-tree-12aa)|Tree, DFS, Recursion, Bit Manipulation
1074|[Number of Submatrices That Sum to Target](https://dev.to/seanpgallivan/solution-number-of-submatrices-that-sum-to-target-3521)|Matrix, Map
1192|[Critical Connections in a Network](https://dev.to/seanpgallivan/solution-critical-connections-in-a-network-51g0)|Tarjan's
1354|[Construct Target Array With Multiple Sums](https://dev.to/seanpgallivan/solution-construct-target-array-with-multiple-sums-24d4)|Priority Queue, Heap
1383|[Maximum Performance of a Team](https://dev.to/seanpgallivan/solution-maximum-performance-of-a-team-244n)|Priority Queue, Heap
1713|[Minimum Operations to Make a Subsequence](https://dev.to/seanpgallivan/solution-minimum-operations-to-make-a-subsequence-48b2)|LCS, LIS, Binary Search
1735|[Count Ways to Make Array With Product](https://dev.to/seanpgallivan/solution-count-ways-to-make-array-with-product-49ji)|Math
1739|[Building Boxes](https://dev.to/seanpgallivan/solution-building-boxes-4keg)|Math

---

###Medium Problem Solutions:
|**#**|**TITLE**|**RELATED TOPICS**|
|---|---|---|
11|[Container With Most Water](https://dev.to/seanpgallivan/solution-container-with-most-water-1907)|Sliding Window
12|[Integer to Roman](https://dev.to/seanpgallivan/solution-integer-to-roman-1n3o)|Math
17|[Letter Combinations of a Phone Number](https://dev.to/seanpgallivan/solution-letter-combinations-of-a-phone-number-1n91)|DFS, Recursion
19|[Remove Nth Node From End of List](https://dev.to/seanpgallivan/solution-remove-nth-node-from-end-of-list-4njl)|Linked List
22|[Generate Parentheses](https://dev.to/seanpgallivan/solution-generate-parentheses-52dk)|Recursion, Bit Manipulation
29|[Divide Two Integers (ver. 1)](https://dev.to/seanpgallivan/solution-divide-two-integers-5dcd)|Bit Manipulation
29|[Divide Two Integers (ver. 2)](https://dev.to/seanpgallivan/solution-divide-two-integers-ver-2-26pp)|Math
31|[Next Permutation](https://dev.to/seanpgallivan/solution-next-permutation-421n)|Array, Math
34|[Find First and Last Position of Element in Sorted Array](https://dev.to/seanpgallivan/solution-find-first-and-last-position-of-element-in-sorted-array-2fg0)|Binary Search
45|[Jump Game II](https://dev.to/seanpgallivan/solution-jump-game-ii-cn3)|Array
48|[Rotate Image](https://dev.to/seanpgallivan/solution-rotate-image-cpp)|Matrix
63|[Unique Paths II](https://dev.to/seanpgallivan/solution-unique-paths-ii-4n2d)|Matrix, DP
71|[Simplify Path](https://dev.to/seanpgallivan/solution-simplify-path-mk)|Stack, Sliding Window
86|[Partition List](https://dev.to/seanpgallivan/solution-partition-list-520f)|Linked List
102|[Binary Tree Level Order Traversal](https://dev.to/seanpgallivan/solution-binary-tree-level-order-traversal-36cg)|Binary Tree, BFS, Level-Order, Queue
105|[Construct Binary Tree from Preorder and Inorder Traversal](https://dev.to/seanpgallivan/solution-construct-binary-tree-from-preorder-and-inorder-traversal-32c5)|Binary Tree, Preorder, Inorder, Recursion
109|[Convert Sorted List to Binary Search Tree](https://dev.to/seanpgallivan/solution-convert-sorted-list-to-binary-search-tree-2i0e)|Tree, Linked List, In-Order, Recursion, Floyd's
114|[Flatten Binary Tree to Linked List](https://dev.to/seanpgallivan/solution-flatten-binary-tree-to-linked-list-599p)|Binary Tree, Pre-Order, Recursion
120|[Triangle](https://dev.to/seanpgallivan/solution-triangle-1lg0)|DP
128|[Longest Consecutive Sequence](https://dev.to/seanpgallivan/solution-longest-consecutive-sequence-27ni)|Map, Array
138|[Copy List with Random Pointer](https://dev.to/seanpgallivan/solution-copy-list-with-random-pointer-48h8)|Linked List
150|[Evaluate Reverse Polish Notation](https://dev.to/seanpgallivan/solution-evaluate-reverse-polish-notation-192l)|Math, Stack
199|[Binary Tree Right Side View](https://dev.to/seanpgallivan/solution-binary-tree-right-side-view-1kj1)|Tree, BFS, DFS, Recursion
240|[Search a 2D Matrix II](https://dev.to/seanpgallivan/solution-search-a-2d-matrix-ii-4lc)|Matrix, Binary Search
284|[Peeking Iterator](https://dev.to/seanpgallivan/solution-peeking-iterator-1io7)|Class
304|[Range Sum Query 2D - Immutable](https://dev.to/seanpgallivan/solution-range-sum-query-2d-immutable-9ic)|Matrix, DP, Prefix Sum
318|[Maximum Product of Word Lengths](https://dev.to/seanpgallivan/solution-maximum-product-of-word-lengths-d62)|Bit Manipulation
322|[Coin Change](https://dev.to/seanpgallivan/solution-coin-change-fg8)|DFS, Recursion
341|[Flatten Nested List Iterator](https://dev.to/seanpgallivan/solution-flatten-nested-list-iterator-483i)|Class, Queue, Recursion
376|[Wiggle Subsequence](https://dev.to/seanpgallivan/solution-wiggle-subsequence-3e65)|Subsequence
377|[Combination Sum IV](https://dev.to/seanpgallivan/solution-combination-sum-iv-3620)|DP
413|[Arithmetic Slices](https://dev.to/seanpgallivan/arithmetic-slices-4pla)|Math
417|[Pacific Atlantic Water Flow](https://dev.to/seanpgallivan/solution-pacific-atlantic-water-flow-4lb3)|DFS, Recursion, DP
423|[Reconstruct Original Digits from English](https://dev.to/seanpgallivan/solution-reconstruct-original-digits-from-english-4o2p)|Frequency Map
462|[Minimum Moves to Equal Array Elements II](https://dev.to/seanpgallivan/solution-minimum-moves-to-equal-array-elements-ii-oej)|Math, Array
473|[Matchsticks to Square](https://dev.to/seanpgallivan/solution-matchsticks-to-square-2fk8)|Backtracking, Recursion
474|[Ones and Zeros](https://dev.to/seanpgallivan/solution-ones-and-zeroes-2emf)|DP
478|[Generate Random Point in a Circle](https://dev.to/seanpgallivan/solution-generate-random-point-in-a-circle-ldh)|Math
524|[Longest Word in Dictionary through Deleting](https://dev.to/seanpgallivan/solution-longest-word-in-dictionary-through-deleting-pd8)|String
535|[Encode and Decode TinyURL](https://dev.to/seanpgallivan/solution-encode-and-decode-tinyurl-4mji)|Map
538|[Convert BST to Greater Tree](https://dev.to/seanpgallivan/solution-convert-bst-to-greater-tree-1j5)|Tree, Inorder
554|[Brick Wall](https://dev.to/seanpgallivan/solution-brick-wall-4jld)|Frequency Map
576|[Out of Boundary Paths](https://dev.to/seanpgallivan/solution-out-of-boundary-paths-2jef)|DP
581|[Shortest Unsorted Continuous Subarray](https://dev.to/seanpgallivan/solution-shortest-unsorted-continuous-subarray-22o2)|Array
583|[Delete Operation for Two Strings](https://dev.to/seanpgallivan/solution-delete-operation-for-two-strings-235k)|LCS, DP
609|[Find Duplicate File in System](https://dev.to/seanpgallivan/solution-find-duplicate-file-in-system-1ofi)|Map, String
622|[Design Circular Queue](https://dev.to/seanpgallivan/solution-design-circular-queue-mdp)|Linked List
623|[Add One Row to Tree](https://dev.to/seanpgallivan/solution-add-one-row-to-tree-1lc2)|Binary Tree, DFS, Recursion
647|[Palindromic Substrings](https://dev.to/seanpgallivan/solution-palindromic-substrings-54jf)|Math
665|[Non-decreasing Array](https://dev.to/seanpgallivan/solution-non-decreasing-array-1m5c)|Array
667|[Beautiful Arrangement II](https://dev.to/seanpgallivan/solution-beautiful-arrangement-ii-1lag)|Math
669|[Trim a Binary Tree](https://dev.to/seanpgallivan/solution-trim-a-binary-search-tree-8ea)|Tree, Recursion
684|[Redundant Connection](https://dev.to/seanpgallivan/solution-redundant-connection-44ha)|Union-Find, Graph
695|[Max Area of Island](https://dev.to/seanpgallivan/solution-max-area-of-island-4njk)|Matrix, DFS, Recursion
714|[Best Time to Buy and Sell Stock with Transaction Fee](https://dev.to/seanpgallivan/solution-best-time-to-buy-and-sell-stock-with-transaction-fee-5dlp)|State Machine
729|[My Calendar I](https://dev.to/seanpgallivan/solution-my-calendar-i-25dm)|Class, Linked List
752|[Open the Lock](https://dev.to/seanpgallivan/solution-open-the-lock-24o3)|Graph, BFS, Queue
775|[Global and Local Inversions](https://dev.to/seanpgallivan/solution-global-and-local-inversions-4f8p)|Math
784|[Letter Case Permutation](https://dev.to/seanpgallivan/solution-letter-case-permutation-5dgn)|Recursion, DFS
785|[Is Graph Bipartite?](https://dev.to/seanpgallivan/solution-is-graph-bipartite-jmp)|BFS, Bit Manipulation
795|[Number of Subarrays with Bounded Maximum](https://dev.to/seanpgallivan/solution-number-of-subarrays-with-bounded-maximum-3mmh)|Math, Array
816|[Ambiguous Coordinates](https://dev.to/seanpgallivan/solution-ambiguous-coordinates-5h03)|String
820|[Short Encoding of Words (ver. 1)](https://dev.to/seanpgallivan/solution-short-encoding-of-words-39g0)|Set
820|[Short Encoding of Words (ver. 2)](https://dev.to/seanpgallivan/solution-short-encoding-of-words-ver-2-423i)|Trie
823|[Binary Trees With Factors](https://dev.to/seanpgallivan/solution-binary-trees-with-factors-2kk4)|Binary Tree, Map, Math
841|[Keys and Rooms](https://dev.to/seanpgallivan/solution-keys-and-rooms-33oh)|DFS
856|[Score of Parentheses](https://dev.to/seanpgallivan/solution-score-of-parentheses-3gh0)|Binary, Math
869|[Reordered Power of 2](https://dev.to/seanpgallivan/solution-reordered-power-of-2-2h57)|Math
870|[Advantage Shuffle](https://dev.to/seanpgallivan/solution-advantage-shuffle-p39)|Array
890|[Find and Replace Pattern](https://dev.to/seanpgallivan/solution-find-and-replace-pattern-2hm)|Map, Mask
916|[Word Subsets](https://dev.to/seanpgallivan/solution-word-subsets-1fnj)|Frequency Map
923|[3Sum With Multiplicity](https://dev.to/seanpgallivan/solution-3sum-with-multiplicity-12ma)|Frequency Map, Combinatorics
946|[Validate Stack Sequences](https://dev.to/seanpgallivan/solution-validate-stack-sequences-46j9)|Stack, 2-Pointer
966|[Vowel Spellchecker](https://dev.to/seanpgallivan/solution-vowel-spellchecker-22o)|Map, Set, Masking
970|[Powerful Integers](https://dev.to/seanpgallivan/solution-powerful-integers-1o2p)|Set
971|[Flip Binary Tree To Match Preorder Traversal](https://dev.to/seanpgallivan/solution-flip-binary-tree-to-match-preorder-traversal-29bh)|Binary Tree, DFS, Recursion
991|[Broken Calculator](https://dev.to/seanpgallivan/solution-broken-calculator-312h)|Math
1048|[Longest String Chain](https://dev.to/seanpgallivan/solution-longest-string-chain-3k9l)|Set, Map, DP
1091|[Shortest Path in Binary Matrix](https://dev.to/seanpgallivan/solution-shortest-path-in-binary-matrix-2an8)|BFS, Matrix, Bit Manipulation
1209|[Remove All Adjacent Duplicates in String II](https://dev.to/seanpgallivan/solution-remove-all-adjacent-duplicates-in-string-ii-431f)|Recursion, Stack
1249|[Minimum Remove to Make Valid Parentheses](https://dev.to/seanpgallivan/solution-minimum-remove-to-make-valid-parentheses-2bdj)|Stack
1268|[Search Suggestions System](https://dev.to/seanpgallivan/solution-search-suggestions-system-90e)|2-Pointer System
1302|[Deepest Leaves Sum](https://dev.to/seanpgallivan/solution-deepest-leaves-sum-1936)|BFS, Queue, DFS, Recursion
1329|[Sort the Matrix Diagonally](https://dev.to/seanpgallivan/solution-sort-the-matrix-diagonally-2k69)|Matrix
1396|[Design Underground System](https://dev.to/seanpgallivan/solution-design-underground-system-5e2i)|Class, Map
1423|[Maximum Points You Can Obtain from Cards](https://dev.to/seanpgallivan/solution-maximum-points-you-can-obtain-from-cards-2no)|Sliding Window
1461|[Check If a String Contains All Binary Codes of Size K](https://dev.to/seanpgallivan/solution-check-if-a-string-contains-all-binary-codes-of-size-k-26gg)|Binary, Bit Manipulation
1465|[Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts](https://dev.to/seanpgallivan/solution-maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts-45p8)|Array, Math
1551|[Minimum Operations to Make Array Equal](https://dev.to/seanpgallivan/solution-minimum-operations-to-make-array-equal-4f2e)|Math
1631|[Path With Minimum Effort](https://dev.to/seanpgallivan/solution-path-with-minimum-effort-36jg)|BFS, Dijkstra's, Heap
1642|[Furthest Building You Can Reach](https://dev.to/seanpgallivan/solution-furthest-building-you-can-reach-1m24)|Heap
1663|[Smallest String With A Given Numeric Value](https://dev.to/seanpgallivan/solution-smallest-string-with-a-given-numeric-value-26kh)|Math
1673|[Find the Most Competitive Subsequence](https://dev.to/seanpgallivan/solution-find-the-most-competitive-subsequence-4b4m)|Stack
1675|[Minimize Deviation in Array](https://dev.to/seanpgallivan/solution-minimize-deviation-in-array-9c0)|Heap
1680|[Concatenation of Consecutive Binary Numbers](https://dev.to/seanpgallivan/solution-concatenation-of-consecutive-binary-numbers-4ach)|Binary, Bit Manipulation
1690|[Stone Game VII](https://dev.to/seanpgallivan/solution-stone-game-vii-3lei)|DP
1695|[Maximum Erasure Value](https://dev.to/seanpgallivan/solution-maximum-erasure-value-1kod)|Array, Sliding Window
1696|[Jump Game VI](https://dev.to/seanpgallivan/solution-jump-game-vi-4a2)|DP, Deque, In-Place, Sliding Window
1717|[Maximum Score From Removing Substrings (ver. 1)](https://dev.to/seanpgallivan/solution-maximum-score-from-removing-substrings-ver-1-39g2)|DP, Stack
1717|[Maximum Score From Removing Substrings (ver. 2)](https://dev.to/seanpgallivan/solution-maximum-score-from-removing-substrings-ver-2-58h1)|String
1721|[Swapping Nodes in a Linked List](https://dev.to/seanpgallivan/solution-swapping-nodes-in-a-linked-list-ie8)|Linked List
1734|[Decode XORed Permutation](https://dev.to/seanpgallivan/solution-decode-xored-permutation-41c2)|Bitwise XOR, Math
1737|[Change Minimum Characters to Satisfy One of Three Conditions](https://dev.to/seanpgallivan/solution-change-minimum-characters-to-satisfy-one-of-three-conditions-11h2)|Frequency Map, Math
1738|[Find Kth Largest XOR Coordinate Value](https://dev.to/seanpgallivan/solution-find-kth-largest-xor-coordinate-value-5d0l)|Bitwise XOR, DP, Heap, Math

---

###Easy Problem Solutions:
|**#**|**TITLE**|**RELATED TOPICS**|
|---|---|---|
13|[Roman to Integer](https://dev.to/seanpgallivan/solution-roman-to-integer-567f)|Math
118|[Pascal's Triangle](https://dev.to/seanpgallivan/solution-pascal-s-triangle-154d)|Array, Math
141|[Linked List Cycle](https://dev.to/seanpgallivan/solution-linked-list-cycle-2e17)|Linked List, Floyd's
160|[Intersection of Two Linked Lists](https://dev.to/seanpgallivan/solution-intersection-of-two-linked-lists-478e)|Linked List
204|[Count Primes](https://dev.to/seanpgallivan/solution-count-primes-4ne8)|Math
242|[Valid Anagram](https://dev.to/seanpgallivan/solution-valid-anagram-3l06)|Frequency Map
243|[Palindrome Linked List](https://dev.to/seanpgallivan/solution-palindrome-linked-list-5721)|Linked List, Floyd's
268|[Missing Number ](https://dev.to/seanpgallivan/solution-missing-number-14e9)|Math
326|[Power of Three](https://dev.to/seanpgallivan/solution-power-of-three-1g6g)|Math
509|[Fibonacci Number](https://dev.to/seanpgallivan/solution-fibonacci-number-32a)|Math
589|[N-ary Tree Preorder Traversal](https://dev.to/seanpgallivan/solution-n-ary-tree-preorder-traversal-506)|Recursion, DFS
594|[Longest Harmonious Subsequence ](https://dev.to/seanpgallivan/solution-longest-harmonious-subsequence-4b1e)|Frequency Map
595|[Distribute Candies](https://dev.to/seanpgallivan/solution-distribute-candies-3kii)|Set
637|[Average of Levels in Binary Tree](https://dev.to/seanpgallivan/solution-average-of-levels-in-binary-tree-13a8)|Binary Tree, BFS
645|[Set Mismatch (ver. 1)](https://dev.to/seanpgallivan/solution-set-mismatch-4ejh)|Array, Math
645|[Set Mismatch (ver. 2)](https://dev.to/seanpgallivan/solution-set-mismatch-ver-2-218b)|Array, Math
696|[Count Binary Substrings](https://dev.to/seanpgallivan/solution-count-binary-substrings-p89)|String, Math
706|[Design HashMap (ver. 1)](https://dev.to/seanpgallivan/solution-design-hashmap-19ee)|Map, Array
706|[Design HashMap (ver. 2)](https://dev.to/seanpgallivan/solution-design-hashmap-ver-2-3ihj)|Hashing Function, Linked List
709|[To Lower Case](https://dev.to/seanpgallivan/solution-to-lower-case-22kh)|String
746|[Min Cost Climbing Stairs](https://dev.to/seanpgallivan/solution-min-cost-climbing-stairs-5ak9)|DP, Array
821|[Shortest Distance to a Character](https://dev.to/seanpgallivan/solution-shortest-distance-to-a-character-ca9)|DP
953|[Verifying an Alien Dictionary](https://dev.to/seanpgallivan/solution-verifying-an-alien-dictionary-76f)|Map
1332|[Remove Palindromic Subsequences](https://dev.to/seanpgallivan/solution-remove-palindromic-subsequences-4683)|String
1337|[The K Weakest Rows in a Matrix (ver. 1)](https://dev.to/seanpgallivan/solution-the-k-weakest-rows-in-a-matrix-2679)|Matrix
1337|[The K Weakest Rows in a Matrix (ver. 2)](https://dev.to/seanpgallivan/solution-the-k-weakest-rows-in-a-matrix-ver-2-1m7c)|Matrix, Binary Search,<br>Heap, Bit Manipulation
1342|[Number of Steps to Reduce a Number to Zero](https://dev.to/seanpgallivan/solution-number-of-steps-to-reduce-a-number-to-zero-5bbb)|Math
1480|[Running Sum of 1d Array](https://dev.to/seanpgallivan/solution-running-sum-of-1d-array-34na)|Prefix Sum
1704|[Determine if String Halves Are Alike](https://dev.to/seanpgallivan/solution-determine-if-string-halves-are-alike-pid)|String
1710|[Maximum Units on a Truck](https://dev.to/seanpgallivan/solution-maximum-units-on-a-truck-ak2)|Sort, Array