Skip to content

SilentSliver/LeetCode

 
 

Repository files navigation

LeetCode

Algorithms in LeetCode by Benhao

Table of Content

How to start

After clone this repo, add a .env file to tell where to locate your problems and solutions (locally). For remote GitHub Action, add COOKIE (LeetCode cookie), PUSH_KEY (PushDeer notification), PROBLEM_FOLDER (where to add problems), USER (LeetCode personal page uri).

Notice: If you want more than just python3, add LANGUAGES="python3,golang" (and so on in .env)

Example .env file:

PROBLEM_FOLDER="problems"
PUSH_KEY="***[key from PushDeer]"
COOKIE="***[cookie from LeetCode graphql]"
LANGUAGES="python3,golang,java,cpp,typescript,rust"
USER="himymben"

install python3.12 requirements:

pip install -r python/requirements.txt

To directly submit Solution to LeetCode, try any language below:

python python/scripts/submit.py -h
# usage: submit.py [-h] [-id ID] {go,py,ts,js,c++,java,golang,python3,typescript,javascript,cpp,rt,rust}
python python/scripts/submit.py python3 -id=1
python python/scripts/submit.py -id=2 py
python python/scripts/submit.py py
python python/scripts/submit.py golang -id=2
python python/scripts/submit.py cpp -id=1
python python/scripts/submit.py java -id=2
python python/scripts/submit.py typescript -id=1
python python/scripts/submit.py rust -id=1

To get any problem you want, try:

python python/scripts/get_problem.py -h
# usage: get_problem.py [-h] [-id PROBLEM_ID] [-slug PROBLEM_SLUG] [-cate PROBLEM_CATEGORY] [-f] [-all] [-pm] [-debug DEBUG_FILE] [-change] [-sl]
python python/scripts/get_problem.py -id=1

To generate daily problems, try:

python python/scripts/daily_auto.py

To fetch daily submits from LeetCode (requires .env COOKIE or USER to be ready), try:

python python/scripts/daily_submission.py

Supported Languages

Python3

Check Python3 README

Golang

Check Golang README

Java

Check Java README

Cpp

Check Cpp README

Typescript

Check TypeScript README

Rust

Check Rust README

Demo

Fork the repo of your own fork.png

Clone your own forked repo

Notice: create your own branch and set it as repo default, and keep master!

Local

Open the code project and installed languages environments as needed.

Test your environment by running languages test, for instance: mvn_test.png if you are facing errors here, contact the author.

Find a cookie from LeetCode (monthly update) cookie.png

Create your own .env file (Notice: better to use a problem folder other than exists as the author is using them, there will be a lot of conflicts):

PROBLEM_FOLDER=demo
COOKIE="***[cookie from LeetCode graphql]"
LANGUAGES="golang,java"

Create the folder 'demo' based on your own .env

Run scripts to fetch problems, run tests and submit your solution.

If you get problem like this, get_problem.png it will add the problem and change the tests of your languages as below: new_problem.png changed_golang.png

In VsCode, add launch.json under .vscode

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Typescript Test",
            "type": "node",
            "request": "launch",
            "preLaunchTask": "typescript-test",
        },
        {
            "name": "Typescript Tests",
            "type": "node",
            "request": "launch",
            "preLaunchTask": "typescript-tests",
        },
        {
            "name": "Python Test",
            "type": "node",
            "request": "launch",
            "preLaunchTask": "python-test",
        },
        {
            "name": "Python Tests",
            "type": "node",
            "request": "launch",
            "preLaunchTask": "python-tests",
        },
        {
            "name": "Golang Test",
            "type": "node",
            "request": "launch",
            "preLaunchTask": "golang-test",
        },
        {
            "name": "Golang Tests",
            "type": "node",
            "request": "launch",
            "preLaunchTask": "golang-tests",
        },
        {
            "name": "C++ Test",
            "type": "node",
            "request": "launch",
            "preLaunchTask": "cpp-test",
        },
        {
            "name": "C++ Tests",
            "type": "node",
            "request": "launch",
            "preLaunchTask": "cpp-tests",
        },
        {
            "name": "Java Test",
            "type": "node",
            "request": "launch",
            "preLaunchTask": "java-test",
        },
        {
            "name": "Java Tests",
            "type": "node",
            "request": "launch",
            "preLaunchTask": "java-tests",
        },
        {
            "name": "Rust Test",
            "type": "node",
            "request": "launch",
            "preLaunchTask": "rust-test",
        },
        {
            "name": "Rust Tests",
            "type": "node",
            "request": "launch",
            "preLaunchTask": "rust-tests",
        }
    ]
}

and tasks.json under .vscode

{
	"version": "2.0.0",
	"tasks": [
		{
			"label": "typescript-test",
			"command": "npm",
			"args": ["test", "--alwaysStric", "--strictBindCallApply", "--strictFunctionTypes", "--target", "ES2022", "typescript/test.ts"],
			"type": "shell"
		},
		{
			"label": "typescript-tests",
			"command": "npm",
			"args": ["test", "--alwaysStric", "--strictBindCallApply", "--strictFunctionTypes", "--target", "ES2022", "typescript/problems.test.ts"],
			"type": "shell"
		},
		{
			"label": "python-test",
			"command": "python",
			"args": ["python/test.py"],
			"type": "shell"
		},
		{
			"label": "python-tests",
			"command": "python",
			"args": ["python/tests.py"],
			"type": "shell"
		},
		{
			"label": "golang-test",
			"command": "go",
			"args": ["test", "golang/solution_test.go", "golang/test_basic.go", "-test.timeout", "3s"],
			"type": "shell"
		},
		{
			"label": "golang-tests",
			"command": "go",
			"args": ["test", "golang/problems_test.go", "golang/test_basic.go", "-test.timeout", "10s"],
			"type": "shell"
		},
		{
			"label": "cpp-test",
			"command": "bazel",
			"args": ["test", "--cxxopt=-std=c++20", "--test_timeout=3", "--test_output=all", "//cpp:solution_test"],
			"type": "shell"
		},
		{
			"label": "cpp-tests",
			"command": "bazel",
			"args": ["test", "--cxxopt=-std=c++20", "--test_timeout=10", "--test_output=all", "//cpp/tests:all"],
			"type": "shell"
		},
		{
			"label": "java-test",
			"command": "mvn",
			"args": ["test", "-Dtest=\"qubhjava.test.TestMain\""],
			"type": "shell"
		},
		{
			"label": "java-tests",
			"command": "mvn",
			"args": ["test", "-Dtest=\"qubhjava.test.ProblemsTest\""],
			"type": "shell"
		},
        {
			"label": "rust-test",
			"command": "cargo",
			"args": ["test", "--test", "solution_test"],
			"type": "shell"
		},
		{
			"label": "rust-tests",
			"command": "cargo",
			"args": ["test", "--test", "solutions_test"],
			"type": "shell"
		}
	]
}

If you want to write c++ in idea better, load this CMakeLists.txt. But still, run test in bazel.

cmake_minimum_required(VERSION 3.28)
project(LeetCodeCpp)

set(CMAKE_CXX_STANDARD 20)

include(FetchContent)
# googletest
FetchContent_Declare(
        googletest
        GIT_REPOSITORY https://github.com/google/googletest.git
        GIT_TAG release-1.10.0 # Specify the version you need
)
FetchContent_MakeAvailable(googletest)

# nlohmann_json
FetchContent_Declare(
        json
        GIT_REPOSITORY https://github.com/nlohmann/json.git
        GIT_TAG v3.9.1 # Specify the version you need
)
FetchContent_MakeAvailable(json)

include_directories(LeetCode)

file(GLOB_RECURSE COMMON_SOURCE LeetCode/cpp/*.cpp LeetCode/cpp/*.h)
file(GLOB_RECURSE PROBLEM_SOLUTIONS LeetCode/problems/*.cpp)
file(GLOB_RECURSE PREMIUMS_SOLUTIONS LeetCode/premiums/*.cpp)

add_executable(LeetCodeCpp
        ${COMMON_SOURCE}
        ${PROBLEM_SOLUTIONS}
        ${PREMIUMS_SOLUTIONS}
)

target_link_libraries(LeetCodeCpp
        gtest_main
        gmock_main
        nlohmann_json::nlohmann_json
)

Solve your problem and enjoy!

Feel free to ask the author and add issues, discussions on GitHub.

GitHub

Config GitHub Action Secrets for daily auto scripts. {SECRETS: TOKEN} github_settings.png

Add values similar to you .env, for example, cookie_key.png

Notice: Add PROBLEM_FOLDER for actions to work properly.

Demo Projects

  1. Benhao Demo (Python3)
  2. SilentSliver Demo (Java)
  3. LazyKindMan Demo (Golang)

Problems

Easy

1480.Running Sum of 1d Array

1431.Kids With the Greatest Number of Candies

1470.Shuffle the Array

1512.Number of Good Pairs

1108.Defanging an IP Address

771.Jewels and Stones

665.Non-decreasing Array

1342.Number of Steps to Reduce a Number to Zero

1528.Shuffle String

1365.How Many Numbers Are Smaller Than the Current Number

1281.Subtract the Product and Sum of Digits of an Integer

1603.Design Parking System

1313.Decompress Run-Length Encoded List

1614.Maximum Nesting Depth of the Parentheses

1389.Create Target Array in the Given Order

1486.XOR Operation in an Array

1221.Split a String in Balanced Strings

1662.Check If Two String Arrays are Equivalent

66.Plus One

1672.Richest Customer Wealth

938.Range Sum of BST

1290.Convert Binary Number in a Linked List to Integer

1588.Sum of All Odd Length Subarrays

1656.Design an Ordered Stream

104.Maximum Depth of Binary Tree Solution

83.Remove Duplicates from Sorted List

897.Increasing Order Search Tree

605.Can Place Flowers

1678.Goal Parser Interpretation

941.Valid Mountain Array

944.Delete Columns to Make Sorted

812.Largest Triangle Area

26.Remove Duplicates from Sorted Array

190.Reverse Bits

1.Two Sum

1684.Count the Number of Consistent Strings

1688.Count of Matches in Tournament

53.Maximum Subarray

977.Squares of a Sorted Array

136.Single Number

1694.Reformat Phone Number

908.Smallest Range I

141.Linked List Cycle

110.Balanced Binary Tree

1030.Matrix Cells in Distance Order

496.Next Greater Element I

1700.Number of Students Unable to Eat Lunch

1704.Determine if String Halves Are Alike

121.Best Time to Buy and Sell Stock

122.Best Time to Buy and Sell Stock II

733.Flood Fill

1640.Check Array Formation Through Concatenation

1710.Maximum Units on a Truck

21.Merge Two Sorted Lists

830.Positions of Large Groups

1539.Kth Missing Positive Number

1716.Calculate Money in Leetcode Bank

1720.Decode XORed Array

88.Merge Sorted Array

1646.Get Maximum in Generated Array

1725.Number Of Rectangles That Can Form The Largest Square

20.Valid Parentheses

1732.Find the Highest Altitude

1736.Latest Time by Replacing Hidden Digits

23.Merge k Sorted Lists

1437.Check If All 1's Are at Least Length K Places Away

1742.Maximum Number of Balls in a Box

191.Number of 1 Bits

594.Longest Harmonious Subsequence

1748.Sum of Unique Elements

1752.Check if Array Is Sorted and Rotated

821.Shortest Distance to a Character

242.Valid Anagram

1758.Minimum Changes To Make Alternating Binary String

1337.The K Weakest Rows in a Matrix

13.Roman to Integer

1763.Longest Nice Substring

1768.Merge Strings Alternately

1773.Count Items Matching a Rule

303.Range Sum Query - Immutable

232.Implement Queue using Stacks

1779.Find Nearest Point That Has the Same X or Y Coordinate

1784.Check if Binary String Has at Most One Segment of Ones

706.Design HashMap

1047.Remove All Adjacent Duplicates In String

224.Basic Calculator

705.Design HashSet

1790.Check if One String Swap Can Make Strings Equal

1796.Second Largest Digit in a String

1800.Maximum Ascending Subarray Sum

1805.Number of Different Integers in a String

1812.Determine Color of a Chessboard Square

1816.Truncate Sentence

263.Ugly Number

1822.Sign of the Product of an Array

783.Minimum Distance Between BST Nodes

530.Minimum Absolute Difference in BST

1827.Minimum Operations to Make the Array Increasing

1832.Check if the Sentence Is Pangram

27.Remove Element

28.Implement strStr()

204.Count Primes

1837.Sum of Digits in Base K

690.Employee Importance

1844.Replace All Digits with Characters

1848.Minimum Distance to the Target Element

7.Reverse Integer

1854.Maximum Population Year

872.Leaf-Similar Trees

1859.Sorting the Sentence

1863.Sum of All Subset XOR Totals

993.Cousins in Binary Tree

1869.Longer Contiguous Segments of Ones than Zeros

1668.Maximum Repeating Substring

461.Hamming Distance

1876.Substrings of Size Three with Distinct Characters

231.Power of Two

1880.Check if Word Equals Summation of Two Words

342.Power of Four

1652.Defuse the Bomb

160.Intersection of Two Linked Lists

203.Remove Linked List Elements

1886.Determine Whether Matrix Can Be Obtained By Rotation

1893.Check if All the Integers in a Range Are Covered

1897.Redistribute Characters to Make All Strings Equal

278.First Bad Version

374.Guess Number Higher or Lower

852.Peak Index in a Mountain Array

1903.Largest Odd Number in String

401.Binary Watch

1909.Remove One Element to Make the Array Strictly Increasing

1913.Maximum Product Difference Between Two Pairs

168.Excel Sheet Column Title

645.Set Mismatch

1920.Build Array from Permutation

225.Implement Stack using Queues

1925.Count Square Sum Triples

1929.Concatenation of Array

155.Min Stack

1935.Maximum Number of Words You Can Type

1941.Check if All Characters Have Equal Number of Occurrences

1945.Sum of Digits of String After Convert

671.Second Minimum Node In a Binary Tree

171.Excel Sheet Column Number

1952.Three Divisors

1957.Delete Characters to Make Fancy String

1137.N-th Tribonacci Number

1961.Check If String Is a Prefix of Array

1967.Number of Strings That Appear as Substrings in Word

551.Student Attendance Record I

345.Reverse Vowels of a String

541.Reverse String II

Medium

2.Add Two Numbers

1476.Subrectangle Queries

646.Maximum Length of Pair Chain

822.Card Flipping Game

165.Compare Version Numbers

382.Linked List Random Node

1492.The kth Factor of n

1680.Concatenation of Consecutive Binary Numbers

1679.Max Number of K-Sum Pairs

117.Populating Next Right Pointers in Each Node II

59.Spiral Matrix II

1010.Pairs of Songs With Total Durations Divisible by 60

592.Fraction Addition and Subtraction

801.Minimum Swaps To Make Sequences Increasing

173.Binary Search Tree Iterator

406.Queue Reconstruction by Height

764.Largest Plus Sign

80.Remove Duplicates from Sorted Array II

1382.Balance a Binary Search Tree

865.Smallest Subtree with all the Deepest Nodes

19.Remove Nth Node From End of List

1685.Sum of Absolute Differences in a Sorted Array

1686.Stone Game VI

1689.Partitioning Into Minimum Number Of Deci-Binary Numbers

1690.Stone Game VII

131.Palindrome Partitioning

29.Divide Two Integers

954.Array of Doubled Pairs

98.Validate Binary Search Tree

454.4Sum II

18.4Sum

15.3Sum

16.3Sum Closest

36.Valid Sudoku

116.Populating Next Right Pointers in Each Node

334.Increasing Triplet Subsequence

1124.Longest Well-Performing Interval

962.Maximum Width Ramp

137.Single Number II

1695.Maximum Erasure Value

1696.Jump Game VI

880.Decoded String at Index

910.Smallest Range II

556.Next Greater Element III

503.Next Greater Element II

24.Swap Nodes in Pairs

498.Diagonal Traverse

1424.Diagonal Traverse II

144.Binary Tree Preorder Traversal

91.Decode Ways

1701.Average Waiting Time

1702.Maximum Binary String After Change

1705.Maximum Number of Eaten Apples

1706.Where Will the Ball Fall

754.Reach a Number

309.Best Time to Buy and Sell Stock with Cooldown

714.Best Time to Buy and Sell Stock with Transaction Fee

1457.Pseudo-Palindromic Paths in a Binary Tree

289.Game of Life

1328.Break a Palindrome

808.Soup Servings

92.Reverse Linked List II

1391.Check if There is a Valid Path in a Grid

1379.Find a Corresponding Node of a Binary Tree in a Clone of That Tree

1711.Count Good Meals

1712.Ways to Split Array Into Three Subarrays

526.Beautiful Arrangement

82.Remove Duplicates from Sorted List II

399.Evaluate Division

547.Number of Provinces

3.Longest Substring Without Repeating Characters

189.Rotate Array

1717.Maximum Score From Removing Substrings

1718.Construct the Lexicographically Largest Valid Sequence

1721.Swapping Nodes in a Linked List

1722.Minimize Hamming Distance After Swap Operations

445.Add Two Numbers II

881.Boats to Save People

1658.Minimum Operations to Reduce X to Zero

215.Kth Largest Element in an Array

470.Implement Rand10() Using Rand7()

1726.Tuple with Same Product

1727.Largest Submatrix With Rearrangements

1641.Count Sorted Vowel Strings

5.Longest Palindromic Substring

1673.Find the Most Competitive Subsequence

1657.Determine if Two Strings Are Close

1329.Sort the Matrix Diagonally

1733.Minimum Number of People to Teach

1734.Decode XORed Permutation

1738.Find Kth Largest XOR Coordinate Value

1737.Change Minimum Characters to Satisfy One of Three Conditions

1631.Path With Minimum Effort

1663.Smallest String With A Given Numeric Value

1743.Restore the Array From Adjacent Pairs

1744.Can You Eat Your Favorite Candy on Your Favorite Day?

31.Next Permutation

669.Trim a Binary Search Tree

142.Linked List Cycle II

71.Simplify Path

199.Binary Tree Right Side View

1749.Maximum Absolute Sum of Any Subarray

1750.Minimum Length of String After Deleting Similar Ends

1753.Maximum Score From Removing Stones

1754.Largest Merge Of Two Strings

284.Peeking Iterator

538.Convert BST to Greater Tree

1038.Binary Search Tree to Greater Sum Tree

138.Copy List with Random Pointer

1091.Shortest Path in Binary Matrix

1759.Count Number of Homogenous Substrings

1760.Minimum Limit of Balls in a Bag

785.Is Graph Bipartite?

784.Letter Case Permutation

11.Container With Most Water

413.Arithmetic Slices

1249.Minimum Remove to Make Valid Parentheses

1764.Form Array by Concatenating Subarrays of Another Array

1765.Map of Highest Peak

991.Broken Calculator

1769.Minimum Number of Operations to Move All Balls to Each Box

1770.Maximum Score from Performing Multiplication Operations

524.Longest Word in Dictionary through Deleting

240.Search a 2D Matrix II

856.Score of Parentheses

581.Shortest Unsorted Continuous Subarray

946.Validate Stack Sequences

1774.Closest Dessert Cost

1775.Equal Sum Arrays With Minimum Number of Operations

304.Range Sum Query 2D - Immutable

338.Counting Bits

1780.Check if Number is a Sum of Powers of Three

1781.Sum of Beauty of All Substrings

1785.Minimum Elements to Add to Form a Given Sum

1786.Number of Restricted Paths From First to Last Node

227.Basic Calculator II

331.Verify Preorder Serialization of a Binary Tree

1791.Find Center of Star Graph

1792.Maximum Average Pass Ratio

54.Spiral Matrix

150.Evaluate Reverse Polish Notation

73.Set Matrix Zeroes

1797.Design Authentication Manager

1798.Maximum Number of Consecutive Values You Can Make

1801.Number of Orders in the Backlog

1802.Maximum Value at a Given Index in a Bounded Array

341.Flatten Nested List Iterator

456.132 Pattern

61.Rotate List

1806.Minimum Number of Operations to Reinitialize a Permutation

1807.Evaluate the Bracket Pairs of a String

74.Search a 2D Matrix

90.Subsets II

1006.Clumsy Factorial

1143.Longest Common Subsequence

1813.Sentence Similarity III

1814.Count Nice Pairs in an Array

781.Rabbits in Forest

1817.Finding the Users Active Minutes

1818.Minimum Absolute Sum Difference

81.Search in Rotated Sorted Array II

153.Find Minimum in Rotated Sorted Array

264.Ugly Number II

1823.Find the Winner of the Circular Game

1824.Minimum Sideway Jumps

179.Largest Number

208.Implement Trie (Prefix Tree)

213.House Robber II

220.Contains Duplicate III

1828.Queries on Number of Points Inside a Circle

1829.Maximum XOR for Each Query

1833.Maximum Ice Cream Bars

1834.Single-Threaded CPU

368.Largest Divisible Subset

377.Combination Sum IV

1838.Frequency of the Most Frequent Element

1839.Longest Substring Of All Vowels in Order

1011.Capacity To Ship Packages Within D Days

633.Sum of Square Numbers

1845.Seat Reservation Manager

1846.Maximum Element After Decreasing and Rearranging

1849.Splitting a String Into Descending Consecutive Values

1850.Minimum Adjacent Swaps to Reach the Kth Smallest Number

554.Brick Wall

17.Letter Combinations of a Phone Number

740.Delete and Earn

1482.Minimum Number of Days to Make m Bouquets

1855.Maximum Distance Between a Pair of Values

1856.Maximum Subarray Min-Product

1310.XOR Queries of a Subarray

337.House Robber III

12.Integer to Roman

1674.Minimum Moves to Make Array Complementary

421.Maximum XOR of Two Numbers in an Array

1860.Incremental Memory Leak

1861.Rotating the Box

1864.Minimum Number of Swaps to Make the Binary String Alternating

1865.Finding Pairs With a Certain Sum

1442.Count Triplets That Can Form Two Arrays of Equal XOR

692.Top K Frequent Words

1035.Uncrossed Lines

1870.Minimum Speed to Arrive on Time

1871.Jump Game VII

1190.Reverse Substrings Between Each Pair of Parentheses

1669.Merge In Between Linked Lists

1670.Design Front Middle Back Queue

477.Total Hamming Distance

1664.Ways to Make a Fair Array

1877.Minimize Maximum Pair Sum in Array

1878.Get Biggest Three Rhombus Sums in a Grid

1881.Maximum Value after Insertion

1882.Process Tasks Using Servers

1642.Furthest Building You Can Reach

523.Continuous Subarray Sum

525.Contiguous Array

1653.Minimum Deletions to Make String Balanced

474.Ones and Zeroes

1887.Reduction Operations to Make the Array Elements Equal

1888.Minimum Number of Flips to Make the Binary String Alternating

494.Target Sum

1049.Last Stone Weight II

518.Coin Change 2

279.Perfect Squares

1894.Find the Student that Will Replace the Chalk

1895.Largest Magic Square

1898.Maximum Number of Removable Characters

1899.Merge Triplets to Form Target Triplet

877.Stone Game

1140.Stone Game II

1239.Maximum Length of a Concatenated String with Unique Characters

1904.The Number of Full Rounds You Have Played

1905.Count Sub Islands

1906.Minimum Absolute Difference Queries

1600.Throne Inheritance

1647.Minimum Deletions to Make Character Frequencies Unique

1648.Sell Diminishing-Valued Colored Balls

752.Open the Lock

909.Snakes and Ladders

1910.Remove All Occurrences of a Substring

1911.Maximum Alternating Subsequence Sum

1914.Cyclically Rotating a Grid

1915.Number of Wonderful Substrings

451.Sort Characters By Frequency

1921.Eliminate Maximum Number of Monsters

1922.Count Good Numbers

1418.Display Table of Food Orders in a Restaurant

930.Binary Subarrays With Sum

981.Time Based Key-Value Store

274.H-Index

1926.Nearest Exit from Entrance in Maze

1927.Sum Game

1930.Unique Length-3 Palindromic Subsequences

275.H-Index II

1936.Add Minimum Number of Rungs

1937.Maximum Number of Points with Cost

695.Max Area of Island

198.House Robber

1942.The Number of the Smallest Unoccupied Chair

1943.Describe the Painting

1946.Largest Number After Mutating Substring

1947.Maximum Compatibility Score Sum

863.All Nodes Distance K in Binary Tree

1104.Path In Zigzag Labelled Binary Tree

1953.Maximum Number of Weeks for Which You Can Work

1954.Minimum Garden Perimeter to Collect Enough Apples

743.Network Delay Time

611.Valid Triangle Number

802.Find Eventual Safe States

207.Course Schedule

210.Course Schedule II

457.Circular Array Loop

1958.Check if Move is Legal

1959.Minimum Total Space Wasted With K Resizing Operations

1962.Remove Stones to Minimize the Total

1963.Minimum Number of Swaps to Make the String Balanced

313.Super Ugly Number

516.Longest Palindromic Subsequence

1583.Count Unhappy Friends

576.Out of Boundary Paths

1968.Array With Elements Not Equal to Average of Neighbors

1969.Minimum Non-Zero Product of the Array Elements

443.String Compression

789.Escape The Ghosts

787.Cheapest Flights Within K Stops

797.All Paths From Source to Target

528.Random Pick with Weight

Hard

1240.Tiling a Rectangle with the Fewest Squares

1095.Find in Mountain Array

188.Best Time to Buy and Sell Stock IV

1681.Minimum Incompatibility

282.Expression Add Operators

37.Sudoku Solver

1687.Delivering Boxes from Storage to Ports

312.Burst Balloons

1691.Maximum Height by Stacking Cuboids

132.Palindrome Partitioning II

1463.Cherry Pickup II

1697.Checking Existence of Edge Length Limited Paths

639.Decode Ways II

1703.Minimum Adjacent Swaps for K Consecutive Ones

1707.Maximum XOR With an Element From Array

1345.Jump Game IV

123.Best Time to Buy and Sell Stock III

84.Largest Rectangle in Histogram

920.Number of Music Playlists

1713.Minimum Operations to Make a Subsequence

878.Nth Magical Number

410.Split Array Largest Sum

127.Word Ladder

1719.Number Of Ways To Reconstruct A Tree

1723.Find Minimum Time to Finish All Jobs

1649.Create Sorted Array through Instructions

1728.Cat and Mouse II

1735.Count Ways to Make Array With Product

1739.Building Boxes

987.Vertical Order Traversal of a Binary Tree

1675.Minimize Deviation in Array

1745.Palindrome Partitioning IV

1751.Maximum Number of Events That Can Be Attended II

1755.Closest Subsequence Sum

1761.Minimum Degree of a Connected Trio in a Graph

51.N-Queens

52.N-Queens II

1766.Tree of Coprimes

1771.Maximize Palindrome Length From Subsequences

1776.Car Fleet II

895.Maximum Frequency Stack

354.Russian Doll Envelopes

1782.Count Pairs Of Nodes

1793.Maximum Score of a Good Subarray

1787.Make the XOR of All Segments Equal to Zero

115.Distinct Subsequences

1799.Maximize Score After N Operations

1803.Count Pairs With XOR in a Range

1808.Maximize Number of Nice Divisors

42.Trapping Rain Water42. Trapping Rain Water

154.Find Minimum in Rotated Sorted Array II

1825.Finding MK Average

87.Scramble String

1835.Find XOR Sum of All Pairs Bitwise AND

363.Max Sum of Rectangle No Larger Than K

1840.Maximum Building Height

403.Frog Jump

1847.Closest Room

1851.Minimum Interval to Include Each Query

1473.Paint House III

1857.Largest Color Value in a Directed Graph

1815.Maximum Number of Groups Getting Fresh Donuts

1819.Number of Different Subsequences GCDs

1269.Number of Ways to Stay in the Same Place After Some Steps

1862.Sum of Floored Pairs

1866.Number of Ways to Rearrange Sticks With K Sticks Visible

810.Chalkboard XOR Game

1872.Stone Game VIII

664.Strange Printer

1671.Minimum Number of Removals to Make Mountain Array

1665.Minimum Initial Energy to Finish Tasks

1074.Number of Submatrices That Sum to Target

1879.Minimum XOR Sum of Two Arrays

1883.Minimum Skips to Arrive at Meeting On Time

1659.Maximize Grid Happiness

1643.Kth Smallest Instructions

1889.Minimum Space Wasted From Packaging

879.Profitable Schemes

1655.Distribute Repeating Integers

1449.Form Largest Integer With Digits That Add up to Target

1896.Minimum Cost to Change the Final Value of Expression

1900.The Earliest and Latest Rounds Where Players Compete

1406.Stone Game III

1510.Stone Game IV

65.Valid Number

1563.Stone Game V

483.Smallest Good Base

149.Max Points on a Line

773.Sliding Puzzle

1912.Design Movie Rental System

1916.Count Ways to Build Rooms in an Ant Colony

815.Bus Routes

297.Serialize and Deserialize Binary Tree

1923.Longest Common Subpath

726.Number of Atoms

887.Super Egg Drop

1928.Minimum Cost to Reach Destination in Time

1931.Painting a Grid With Three Different Colors

1932.Merge BSTs to Create Single BST

218.The Skyline Problem

1938.Maximum Genetic Difference Query

1944.Number of Visible People in a Queue

1948.Delete Duplicate Folders in System

1955.Count Number of Special Subsequences

847.Shortest Path Visiting All Nodes

1964.Find the Longest Valid Obstacle Course at Each Position

446.Arithmetic Slices II - Subsequence

1970.Last Day Where You Can Still Cross

552.Student Attendance Record II

295.Find Median from Data Stream

Mysql

1179.Reformat Department Table

LCP

01.猜数字

02.分式化简

03.机器人大冒险

04.覆盖

07.传递信息

28.采购方案

29.乐团站位

30.魔塔游戏

31.变换的迷宫

32.批量处理任务

33.蓄水

34.二叉树染色

35.电动车游城市

36.最多牌组数

Interview

03.01.三合一

10.02.变位词组

17.10.主要元素

17.21.直方图的水量

剑指 Offer

38.字符串的排列

42.连续子数组的最大和

52.两个链表的第一个公共节点

53-I.在排序数组中查找数字 I

About

Algorithms I wrote in LeetCode

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 78.5%
  • Java 6.9%
  • C++ 5.9%
  • Go 5.0%
  • TypeScript 3.1%
  • Rust 0.4%
  • Other 0.2%