DEV Community

Cover image for Leetcode Solutions Index

Posted on • Updated on

Leetcode Solutions Index

This is the master index for my series of Leetcode solution explanations. If you like these solutions or found them useful, please like this post.

Hard Problem Solutions:

32 Longest Valid Parentheses Stack
51 N-Queens Backtracking, DFS, Recursion, Bit Manipulation
52 N-Queens II Backtracking, DFS, Recursion, Bit Manipulation
65 Valid Number String
164 Maximum Gap Bucket Sort, Math
329 Longest Increasing Path in a Matrix Recursion, DFS, Memoization
336 Palindrome Pairs Map
354 Russian Doll Envelopes LIS, Binary Search, DP
630 Course Schedule III Priority Queue, Heap
745 Prefix and Suffix Search Trie
778 Swim in Rising Water Dijkstra's, Priority Queue, Heap
871 Minimum Number of Refueling Stops Max Priority Queue, Max Heap, Greedy
895 Maximum Frequency Stack Frequency Map, Stack
906 Super Palindromes Math, Palindromes
936 Stamping The Sequence Character Mask
968 Binary Tree Cameras DFS, Recursion
987 Vertical Order Traversal of a Binary Tree Tree, DFS, Recursion, Bit Manipulation
1074 Number of Submatrices That Sum to Target Matrix, Map
1192 Critical Connections in a Network Tarjan's
1354 Construct Target Array With Multiple Sums Priority Queue, Heap
1383 Maximum Performance of a Team Priority Queue, Heap
1713 Minimum Operations to Make a Subsequence LCS, LIS, Binary Search
1735 Count Ways to Make Array With Product Math
1739 Building Boxes Math

Medium Problem Solutions:

11 Container With Most Water Sliding Window
12 Integer to Roman Math
17 Letter Combinations of a Phone Number DFS, Recursion
19 Remove Nth Node From End of List Linked List
22 Generate Parentheses Recursion, Bit Manipulation
29 Divide Two Integers (ver. 1) Bit Manipulation
29 Divide Two Integers (ver. 2) Math
31 Next Permutation Array, Math
34 Find First and Last Position of Element in Sorted Array Binary Search
45 Jump Game II Array
48 Rotate Image Matrix
63 Unique Paths II Matrix, DP
71 Simplify Path Stack, Sliding Window
86 Partition List Linked List
102 Binary Tree Level Order Traversal Binary Tree, BFS, Level-Order, Queue
105 Construct Binary Tree from Preorder and Inorder Traversal Binary Tree, Preorder, Inorder, Recursion
109 Convert Sorted List to Binary Search Tree Tree, Linked List, In-Order, Recursion, Floyd's
114 Flatten Binary Tree to Linked List Binary Tree, Pre-Order, Recursion
120 Triangle DP
128 Longest Consecutive Sequence Map, Array
138 Copy List with Random Pointer Linked List
150 Evaluate Reverse Polish Notation Math, Stack
199 Binary Tree Right Side View Tree, BFS, DFS, Recursion
240 Search a 2D Matrix II Matrix, Binary Search
284 Peeking Iterator Class
304 Range Sum Query 2D - Immutable Matrix, DP, Prefix Sum
318 Maximum Product of Word Lengths Bit Manipulation
322 Coin Change DFS, Recursion
341 Flatten Nested List Iterator Class, Queue, Recursion
376 Wiggle Subsequence Subsequence
377 Combination Sum IV DP
413 Arithmetic Slices Math
417 Pacific Atlantic Water Flow DFS, Recursion, DP
423 Reconstruct Original Digits from English Frequency Map
462 Minimum Moves to Equal Array Elements II Math, Array
473 Matchsticks to Square Backtracking, Recursion
474 Ones and Zeros DP
478 Generate Random Point in a Circle Math
524 Longest Word in Dictionary through Deleting String
535 Encode and Decode TinyURL Map
538 Convert BST to Greater Tree Tree, Inorder
554 Brick Wall Frequency Map
576 Out of Boundary Paths DP
581 Shortest Unsorted Continuous Subarray Array
583 Delete Operation for Two Strings LCS, DP
609 Find Duplicate File in System Map, String
622 Design Circular Queue Linked List
623 Add One Row to Tree Binary Tree, DFS, Recursion
647 Palindromic Substrings Math
665 Non-decreasing Array Array
667 Beautiful Arrangement II Math
669 Trim a Binary Tree Tree, Recursion
684 Redundant Connection Union-Find, Graph
695 Max Area of Island Matrix, DFS, Recursion
714 Best Time to Buy and Sell Stock with Transaction Fee State Machine
729 My Calendar I Class, Linked List
752 Open the Lock Graph, BFS, Queue
775 Global and Local Inversions Math
784 Letter Case Permutation Recursion, DFS
785 Is Graph Bipartite? BFS, Bit Manipulation
795 Number of Subarrays with Bounded Maximum Math, Array
816 Ambiguous Coordinates String
820 Short Encoding of Words (ver. 1) Set
820 Short Encoding of Words (ver. 2) Trie
823 Binary Trees With Factors Binary Tree, Map, Math
841 Keys and Rooms DFS
856 Score of Parentheses Binary, Math
869 Reordered Power of 2 Math
870 Advantage Shuffle Array
890 Find and Replace Pattern Map, Mask
916 Word Subsets Frequency Map
923 3Sum With Multiplicity Frequency Map, Combinatorics
946 Validate Stack Sequences Stack, 2-Pointer
966 Vowel Spellchecker Map, Set, Masking
970 Powerful Integers Set
971 Flip Binary Tree To Match Preorder Traversal Binary Tree, DFS, Recursion
991 Broken Calculator Math
1048 Longest String Chain Set, Map, DP
1091 Shortest Path in Binary Matrix BFS, Matrix, Bit Manipulation
1209 Remove All Adjacent Duplicates in String II Recursion, Stack
1249 Minimum Remove to Make Valid Parentheses Stack
1268 Search Suggestions System 2-Pointer System
1302 Deepest Leaves Sum BFS, Queue, DFS, Recursion
1329 Sort the Matrix Diagonally Matrix
1396 Design Underground System Class, Map
1423 Maximum Points You Can Obtain from Cards Sliding Window
1461 Check If a String Contains All Binary Codes of Size K Binary, Bit Manipulation
1465 Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts Array, Math
1551 Minimum Operations to Make Array Equal Math
1631 Path With Minimum Effort BFS, Dijkstra's, Heap
1642 Furthest Building You Can Reach Heap
1663 Smallest String With A Given Numeric Value Math
1673 Find the Most Competitive Subsequence Stack
1675 Minimize Deviation in Array Heap
1680 Concatenation of Consecutive Binary Numbers Binary, Bit Manipulation
1690 Stone Game VII DP
1695 Maximum Erasure Value Array, Sliding Window
1696 Jump Game VI DP, Deque, In-Place, Sliding Window
1717 Maximum Score From Removing Substrings (ver. 1) DP, Stack
1717 Maximum Score From Removing Substrings (ver. 2) String
1721 Swapping Nodes in a Linked List Linked List
1734 Decode XORed Permutation Bitwise XOR, Math
1737 Change Minimum Characters to Satisfy One of Three Conditions Frequency Map, Math
1738 Find Kth Largest XOR Coordinate Value Bitwise XOR, DP, Heap, Math

Easy Problem Solutions:

13 Roman to Integer Math
118 Pascal's Triangle Array, Math
141 Linked List Cycle Linked List, Floyd's
160 Intersection of Two Linked Lists Linked List
204 Count Primes Math
242 Valid Anagram Frequency Map
243 Palindrome Linked List Linked List, Floyd's
268 Missing Number Math
326 Power of Three Math
509 Fibonacci Number Math
589 N-ary Tree Preorder Traversal Recursion, DFS
594 Longest Harmonious Subsequence Frequency Map
595 Distribute Candies Set
637 Average of Levels in Binary Tree Binary Tree, BFS
645 Set Mismatch (ver. 1) Array, Math
645 Set Mismatch (ver. 2) Array, Math
696 Count Binary Substrings String, Math
706 Design HashMap (ver. 1) Map, Array
706 Design HashMap (ver. 2) Hashing Function, Linked List
709 To Lower Case String
746 Min Cost Climbing Stairs DP, Array
821 Shortest Distance to a Character DP
953 Verifying an Alien Dictionary Map
1332 Remove Palindromic Subsequences String
1337 The K Weakest Rows in a Matrix (ver. 1) Matrix
1337 The K Weakest Rows in a Matrix (ver. 2) Matrix, Binary Search,
Heap, Bit Manipulation
1342 Number of Steps to Reduce a Number to Zero Math
1480 Running Sum of 1d Array Prefix Sum
1704 Determine if String Halves Are Alike String
1710 Maximum Units on a Truck Sort, Array

Top comments (2)

rsousaj profile image
Rafael Sousa

Pretty cool Sean. I'll definitely keep eyes on this series.
Actually, I'll make it better. I'll study one of them a day.


seanpgallivan profile image

You're welcome, Rafael!

I've been doing the daily leetcode challenge problem pretty much every day for the past 8 months, and I will definitely agree that a little bit each day really helps!