DEV Community

loading...

Leetcode Solutions Series' Articles

Back to seanpgallivan's Series
Solution: Next Permutation

Solution: Next Permutation

Reactions 50 Comments
3 min read
Solution: Trim a Binary Search Tree

Solution: Trim a Binary Search Tree

Reactions 11 Comments
3 min read
Leetcode Solutions Index

Leetcode Solutions Index

Reactions 20 Comments 2
7 min read
Solution: Minimize Deviation in Array

Solution: Minimize Deviation in Array

Reactions 5 Comments 2
4 min read
Solution: Vertical Order Traversal of a Binary Tree

Solution: Vertical Order Traversal of a Binary Tree

Reactions 3 Comments
4 min read
Solution: Count Ways to Make Array With Product

Solution: Count Ways to Make Array With Product

Reactions 3 Comments
5 min read
Solution: Smallest String With A Given Numeric Value

Solution: Smallest String With A Given Numeric Value

Reactions 2 Comments 2
3 min read
Solution: Linked List Cycle

Solution: Linked List Cycle

Reactions 5 Comments
3 min read
Solution: Path With Minimum Effort

Solution: Path With Minimum Effort

Reactions 5 Comments
4 min read
Solution: Concatenation of Consecutive Binary Numbers

Solution: Concatenation of Consecutive Binary Numbers

Reactions 5 Comments
2 min read
Solution: Minimum Operations to Make a Subsequence

Solution: Minimum Operations to Make a Subsequence

Reactions 6 Comments
3 min read
Solution: Longest Harmonious Subsequence

Solution: Longest Harmonious Subsequence

Reactions 4 Comments
2 min read
Solution: Simplify Path

Solution: Simplify Path

Reactions 5 Comments
3 min read
Solution: Building Boxes

Solution: Building Boxes

Reactions 4 Comments
3 min read
Solution: Decode XORed Permutation

Solution: Decode XORed Permutation

Reactions 4 Comments
3 min read
Solution: Binary Tree Right Side View

Solution: Binary Tree Right Side View

Reactions 6 Comments
2 min read
Solution: Find Kth Largest XOR Coordinate Value

Solution: Find Kth Largest XOR Coordinate Value

Reactions 6 Comments
5 min read
Solution: Change Minimum Characters to Satisfy One of Three Conditions

Solution: Change Minimum Characters to Satisfy One of Three Conditions

Reactions 6 Comments
5 min read
Solution: Shortest Distance to a Character

Solution: Shortest Distance to a Character

Reactions 6 Comments
3 min read
Solution: Peeking Iterator

Solution: Peeking Iterator

Reactions 4 Comments
3 min read
Solution: Convert BST to Greater Tree

Solution: Convert BST to Greater Tree

Reactions 6 Comments
2 min read
Solution: Copy List with Random Pointer

Solution: Copy List with Random Pointer

Reactions 6 Comments
3 min read
Solution: Valid Anagram

Solution: Valid Anagram

Reactions 6 Comments
2 min read
Solution: Number of Steps to Reduce a Number to Zero

Solution: Number of Steps to Reduce a Number to Zero

Reactions 5 Comments 3
2 min read
Solution: Shortest Path in Binary Matrix

Solution: Shortest Path in Binary Matrix

Reactions 8 Comments
5 min read
Solution: Is Graph Bipartite?

Solution: Is Graph Bipartite?

Reactions 5 Comments
4 min read
Solution: Maximum Score From Removing Substrings (ver. 1)

Solution: Maximum Score From Removing Substrings (ver. 1)

Reactions 6 Comments
4 min read
Solution: Maximum Score From Removing Substrings (ver. 2)

Solution: Maximum Score From Removing Substrings (ver. 2)

Reactions 9 Comments
4 min read
Solution: Sort the Matrix Diagonally

Solution: Sort the Matrix Diagonally

Reactions 7 Comments
4 min read
Solution: The K Weakest Rows in a Matrix (ver. 1)

Solution: The K Weakest Rows in a Matrix (ver. 1)

Reactions 6 Comments
4 min read
Solution: The K Weakest Rows in a Matrix (ver. 2)

Solution: The K Weakest Rows in a Matrix (ver. 2)

Reactions 9 Comments
5 min read
Solution: Letter Case Permutation

Solution: Letter Case Permutation

Reactions 8 Comments 1
3 min read
Solution: Container With Most Water

Solution: Container With Most Water

Reactions 15 Comments
4 min read
Solution: Arithmetic Slices

Solution: Arithmetic Slices

Reactions 9 Comments
4 min read
Solution: Minimum Remove to Make Valid Parentheses

Solution: Minimum Remove to Make Valid Parentheses

Reactions 7 Comments 1
4 min read
Solution: Roman to Integer

Solution: Roman to Integer

Reactions 44 Comments 4
4 min read
Solution: Broken Calculator

Solution: Broken Calculator

Reactions 9 Comments 2
4 min read
Solution: Find the Most Competitive Subsequence

Solution: Find the Most Competitive Subsequence

Reactions 4 Comments
3 min read
Solution: Longest Word in Dictionary through Deleting

Solution: Longest Word in Dictionary through Deleting

Reactions 4 Comments
3 min read
Solution: Search a 2D Matrix II

Solution: Search a 2D Matrix II

Reactions 3 Comments
3 min read
Solution: Score of Parentheses

Solution: Score of Parentheses

Reactions 7 Comments
3 min read
Solution: Shortest Unsorted Continuous Subarray

Solution: Shortest Unsorted Continuous Subarray

Reactions 6 Comments
4 min read
Solution: Validate Stack Sequences

Solution: Validate Stack Sequences

Reactions 6 Comments
3 min read
Solution: Divide Two Integers (ver. 1)

Solution: Divide Two Integers (ver. 1)

Reactions 7 Comments
4 min read
Solution: Divide Two Integers (ver. 2)

Solution: Divide Two Integers (ver. 2)

Reactions 6 Comments
3 min read
Solution: Maximum Frequency Stack

Solution: Maximum Frequency Stack

Reactions 8 Comments
4 min read
Solution: Distribute Candies

Solution: Distribute Candies

Reactions 6 Comments
3 min read
Solution: Set Mismatch (ver. 1)

Solution: Set Mismatch (ver. 1)

Reactions 7 Comments
3 min read
Solution: Set Mismatch (ver. 2)

Solution: Set Mismatch (ver. 2)

Reactions 9 Comments 4
3 min read
Solution: Missing Number

Solution: Missing Number

Reactions 6 Comments 3
2 min read
Solution: Intersection of Two Linked Lists

Solution: Intersection of Two Linked Lists

Reactions 34 Comments
4 min read
Solution: Average of Levels in Binary Tree

Solution: Average of Levels in Binary Tree

Reactions 12 Comments
3 min read
Solution: Short Encoding of Words (ver. 1)

Solution: Short Encoding of Words (ver. 1)

Reactions 6 Comments
4 min read
Solution: Design HashMap (ver. 1)

Solution: Design HashMap (ver. 1)

Reactions 22 Comments 3
3 min read
Solution: Short Encoding of Words (ver. 2)

Solution: Short Encoding of Words (ver. 2)

Reactions 8 Comments
5 min read
Solution: Design HashMap (ver. 2)

Solution: Design HashMap (ver. 2)

Reactions 18 Comments
6 min read
Solution: Remove Palindromic Subsequences

Solution: Remove Palindromic Subsequences

Reactions 5 Comments
3 min read
Solution: Add One Row to Tree

Solution: Add One Row to Tree

Reactions 13 Comments
4 min read
Solution: Integer to Roman

Solution: Integer to Roman

Reactions 12 Comments
3 min read
Solution: Coin Change

Solution: Coin Change

Reactions 11 Comments 1
4 min read
Solution: Check If a String Contains All Binary Codes of Size K

Solution: Check If a String Contains All Binary Codes of Size K

Reactions 13 Comments
4 min read
Solution: Binary Trees With Factors

Solution: Binary Trees With Factors

Reactions 9 Comments 2
4 min read
Solution: Swapping Nodes in a Linked List

Solution: Swapping Nodes in a Linked List

Reactions 16 Comments
3 min read
Solution: Encode and Decode TinyURL

Solution: Encode and Decode TinyURL

Reactions 14 Comments
3 min read
Solution: Best Time to Buy and Sell Stock with Transaction Fee

Solution: Best Time to Buy and Sell Stock with Transaction Fee

Reactions 13 Comments
4 min read
Solution: Generate Random Point in a Circle

Solution: Generate Random Point in a Circle

Reactions 24 Comments
4 min read
Solution: Wiggle Subsequence

Solution: Wiggle Subsequence

Reactions 7 Comments
3 min read
Solution: Keys and Rooms

Solution: Keys and Rooms

Reactions 19 Comments
3 min read
Solution: Design Underground System

Solution: Design Underground System

Reactions 11 Comments
5 min read
Solution: Reordered Power of 2

Solution: Reordered Power of 2

Reactions 5 Comments
3 min read
Solution: Vowel Spellchecker

Solution: Vowel Spellchecker

Reactions 15 Comments
5 min read
Solution: 3Sum With Multiplicity

Solution: 3Sum With Multiplicity

Reactions 6 Comments
6 min read
Solution: Advantage Shuffle

Solution: Advantage Shuffle

Reactions 9 Comments
4 min read
Solution: Pacific Atlantic Water Flow

Solution: Pacific Atlantic Water Flow

Reactions 7 Comments
5 min read
Solution: Word Subsets

Solution: Word Subsets

Reactions 8 Comments 2
5 min read
Solution: Palindromic Substrings

Solution: Palindromic Substrings

Reactions 9 Comments
3 min read
Solution: Reconstruct Original Digits from English

Solution: Reconstruct Original Digits from English

Reactions 6 Comments
4 min read
Solution: Flip Binary Tree To Match Preorder Traversal

Solution: Flip Binary Tree To Match Preorder Traversal

Reactions 7 Comments
4 min read
Solution: Russian Doll Envelopes

Solution: Russian Doll Envelopes

Reactions 9 Comments
4 min read
Solution: Stamping The Sequence

Solution: Stamping The Sequence

Reactions 7 Comments
5 min read
Solution: Palindrome Linked List

Solution: Palindrome Linked List

Reactions 16 Comments
4 min read
Solution: Ones and Zeroes

Solution: Ones and Zeroes

Reactions 17 Comments
4 min read
Solution: Longest Valid Parentheses

Solution: Longest Valid Parentheses

Reactions 13 Comments 4
4 min read
Solution: Design Circular Queue

Solution: Design Circular Queue

Reactions 14 Comments 1
7 min read
Solution: Global and Local Inversions

Solution: Global and Local Inversions

Reactions 11 Comments
3 min read
Solution: Minimum Operations to Make Array Equal

Solution: Minimum Operations to Make Array Equal

Reactions 10 Comments
4 min read
Solution: Determine if String Halves Are Alike

Solution: Determine if String Halves Are Alike

Reactions 9 Comments
3 min read
Solution: Letter Combinations of a Phone Number

Solution: Letter Combinations of a Phone Number

Reactions 16 Comments 1
4 min read
Solution: Verifying an Alien Dictionary

Solution: Verifying an Alien Dictionary

Reactions 9 Comments
4 min read
Solution: Longest Increasing Path in a Matrix

Solution: Longest Increasing Path in a Matrix

Reactions 7 Comments
4 min read
Solution: Deepest Leaves Sum

Solution: Deepest Leaves Sum

Reactions 6 Comments
4 min read
Solution: Beautiful Arrangement II

Solution: Beautiful Arrangement II

Reactions 12 Comments
4 min read
Solution: Flatten Nested List Iterator

Solution: Flatten Nested List Iterator

Reactions 11 Comments 1
3 min read
Solution: Partition List

Solution: Partition List

Reactions 12 Comments 2
3 min read
Solution: Fibonacci Number

Solution: Fibonacci Number

Reactions 9 Comments
3 min read
Solution: Remove All Adjacent Duplicates in String II

Solution: Remove All Adjacent Duplicates in String II

Reactions 14 Comments 2
5 min read
Solution: Number of Submatrices That Sum to Target

Solution: Number of Submatrices That Sum to Target

Reactions 4 Comments
4 min read