The Doocs LeetCode repository is a comprehensive collection of solutions to LeetCode questions in multiple programming languages. The repository contains solutions to LeetCode, LCOF, LCCI questions, and more in multiple programming languages.
The repository is maintained by the Doocs community, and please give us a star 🌟 if you like it.
- Vercel: https://doocs-leetcode.vercel.app
- GitHub Pages: https://doocs.github.io/leetcode
- LeetCode
- Past Contests
- LCOF: Coding Interviews, 2nd Edition
- LCCI: Cracking the Coding Interview, 6th Edition
- Find First and Last Position of Element in Sorted Array -
Binary search
- Minimum Speed to Arrive on Time -
Binary search
- Find the Student that Will Replace the Chalk -
Binary search
- Maximum Number of Removable Characters -
Binary search
- Sort an Array -
Quick Sort
,Merge Sort
- Add Strings -
Addition of large numbers
- Multiply Strings -
Multiply large numbers
- Range Sum Query - Immutable -
Prefix sum
- Range Sum Query 2D - Immutable -
Prefix sum
- Range Addition -
Prefix sum
,Difference array
- Stamping the Grid -
Prefix sum
,Difference array
- Longest Substring Without Repeating Characters -
Two pointers
,Hash table
- Subarray Product Less Than K -
Two pointers
- Number of 1 Bits -
Bit manipulation
,Lowbit
- Merge Intervals -
Merge intervals
- Design Linked List -
Linked List
,Pointer
,Array
- Next Greater Element I -
Monotonic Stack
- Daily Temperatures -
Monotonic Stack
- Max Chunks To Make Sorted II -
Monotonic Stack
- Sum of Subarray Minimums -
Monotonic Stack
- Maximum Width Ramp -
Monotonic Stack
- Sum of Subarray Ranges -
Monotonic Stack
- Maximum Subarray Min-Product -
Monotonic Stack
- Sliding Window Maximum -
Monotonic Queue
- Max Value of Equation -
Monotonic Queue
- Shortest Subarray with Sum at Least K -
Monotonic Queue
- Constrained Subsequence Sum -
Dynamic Programming
,Monotonic Queue
- Word Pattern II -
Hash Table
、Backtracking
- Shortest Palindrome -
Rabin-Karp
- Palindrome Pairs -
Rabin-Karp
- Longest Duplicate Substring -
Rabin-Karp
,Binary search
- Distinct Echo Substrings -
Rabin-Karp
- Flood Fill -
BFS
,DFS
,Flood fill
- Number of Islands -
BFS
,Flood fill
- 01 Matrix -
BFS with multiple sources
- Map of Highest Peak -
BFS with multiple sources
- Minimum Knight Moves -
BFS
,Shortest paths model
- Shortest Path in Binary Matrix -
BFS
,Shortest paths model
- Nearest Exit from Entrance in Maze -
BFS
,Shortest paths model
- Shortest Path in a Grid with Obstacles Elimination -
BFS
,Shortest paths model
- Open the Lock -
Minimum steps model
,Two-end BFS
,A* search
- Word Ladder -
Minimum steps model
,Two-end BFS
- Minimum Operations to Convert Number -
Minimum steps model
,Two-end BFS
- Sliding Puzzle - BFS,
Minimum steps model
,A* search
- Shortest Path Visiting All Nodes -
BFS
,Minimum steps model
,A* search
- Cut Off Trees for Golf Event -
BFS
,A* search
- Minimum Cost to Make at Least One Valid Path in a Grid -
BFS using deque
- Minimum Cost to Make at Least One Valid Path in a Grid -
BFS using deque
- The Maze -
DFS, Flood fill
- Word Search -
DFS
,Backtracking
- Path with Maximum Gold -
DFS
,Backtracking
- Matchsticks to Square -
DFS
,Backtracking
- Partition to K Equal Sum Subsets -
DFS
,Backtracking
- Find Minimum Time to Finish All Jobs -
DFS
,Backtracking
- Fair Distribution of Cookies -
DFS
,Backtracking
- Longest Increasing Path in a Matrix -
DFS
、Memoization
- Number of Increasing Paths in a Grid -
DFS
、Memoization
- Flip Game II -
DFS
、Bitmask
、Memoization
- Count All Possible Routes -
DFS
、Memoization
- Number of Ways of Cutting a Pizza -
DFS
、Memoization
- Pascal's Triangle -
Linear problem
- Minimum Path Sum -
Linear problem
- Cherry Pickup -
Linear problem
- Cherry Pickup II -
Linear problem
- Longest Increasing Subsequence -
Linear problem
,LIS
- Non-overlapping Intervals -
Linear problem
,LIS
,Greedy
- Delete Columns to Make Sorted III -
Linear problem
,LIS
- Russian Doll Envelopes -
Linear problem
,LIS
- Maximum Height by Stacking Cuboids -
Sort
,Linear problem
,LIS
- Best Team With No Conflicts -
Sort
,Linear problem
,LIS
- Longest Common Subsequence -
Linear problem
,LCS
- Minimum ASCII Delete Sum for Two Strings -
Linear problem
,LCS
- Delete Operation for Two Strings -
Linear problem
,LCS
- Target Sum -
0-1 Knapsack problem
- Partition Equal Subset Sum -
0-1 Knapsack problem
- Last Stone Weight II -
0-1 Knapsack problem
- Coin Change -
Unbounded Knapsack problem
- Combination Sum IV -
Unbounded Knapsack problem
- Maximum Value of K Coins From Piles -
Group Knapsack problem
- Number of Digit One -
Digit DP problem
,Memoization
- Count Numbers with Unique Digits -
Digit DP problem
,Memoization
- Non-negative Integers without Consecutive Ones -
Digit DP problem
,Memoization
- Rotated Digits -
Digit DP problem
,Memoization
- Numbers At Most N Given Digit Set -
Digit DP problem
,Memoization
- Count Special Integers -
Digit DP problem
,Memoization
- Detect Cycles in 2D Grid -
Union find
,Detect cycles
- Evaluate Division -
Union find
- Regions Cut By Slashes -
Union find
- Swim in Rising Water -
Union find
- Smallest String With Swaps -
Union find
- Bricks Falling When Hit -
Union find
,Reversed thinking
- Minimize Malware Spread II -
Union find
,Reversed thinking
- Checking Existence of Edge Length Limited Paths -
Union find
,Offline algorithm
- Remove Max Number of Edges to Keep Graph Fully Traversable -
Two Union find
- Range Sum Query - Mutable -
Binary Indexed Tree
,Segment Tree
- Create Sorted Array through Instructions -
Binary Indexed Tree
,Segment Tree
- Count Good Triplets in an Array -
Binary Indexed Tree
,Segment Tree
- Minimum Possible Integer After at Most K Adjacent Swaps On Digits -
Binary Indexed Tree
- Range Sum Query 2D - Mutable -
Binary Indexed Tree 2D
,Segment Tree
- Count of Smaller Numbers After Self -
Binary Indexed Tree
,Discretization
,Segment Tree
- Count of Range Sum -
Binary Indexed Tree
,Discretization
,Segment Tree
- Reverse Pairs -
Binary Indexed Tree
,Discretization
,Divide and Conquer
,Segment Tree
- Number of Longest Increasing Subsequence -
Binary Indexed Tree
,Discretization
,Interval maximum
- Fancy Sequence -
Dynamic Segment Tree
,Lazy Propogation
- Range Module -
Dynamic Segment Tree
,Lazy Propogation
- My Calendar III -
Dynamic Segment Tree
,Lazy Propogation
- Amount of New Area Painted Each Day -
Dynamic Segment Tree
,Lazy Propogation
- Longest Substring of One Repeating Character -
Segment Tree
- Rectangle Area II -
Segment Tree
,Discretization
,Line Sweep
- Network Delay Time -
Shortest Path
,Dijkstra's algorithm
,Bellman Ford's algorithm
,SPFA
- Minimum Weighted Subgraph With the Required Paths -
Shortest Path
,Dijkstra's algorithm
- Min Cost to Connect All Points -
Minimum Spanning Tree
,Prim's algorithm
,Kruskal's algorithm
,Union find
- Connecting Cities With Minimum Cost -
Minimum Spanning Tree
,Kruskal's algorithm
- Optimize Water Distribution in a Village -
Minimum Spanning Tree
,Kruskal's algorithm
,Union find
- Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree -
Minimum Spanning Tree
,Kruskal's algorithm
,Union find
- Is Graph Bipartite? -
Graph coloring
,Union find
I'm looking for long-term contributors/partners to this repo! Send me PRs if you're interested! See the following:
- Fork this repository to your own GitHub account and then clone it to your local machine.
- Checkout a new branch.
- Make some changes to your leetcode repository, then push the changes to your remote GitHub repository.
- Create a pull request with your changes!
- See CONTRIBUTING or GitHub Help for more details.
You can also contribute to doocs/leetcode using Gitpod.io, a free online dev environment with a single click.
This project exists thanks to all the people who contribute.
Thank you to all our backers and sponsors!
"You help the developer community practice for interviews, and there is nothing better we could ask for." -- Alan Yessenbayev
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.