Need help with LeetCode?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

428 Stars 104 Forks Other 98 Commits 0 Opened issues


Solutions of LeetCode Online Judge

Services available


Need anything else?

Contributors list

# 15,334
Arch Li...
94 commits
# 576,398
1 commit
# 539,157
1 commit


LeetCode solutions gives some thoughts on selected problems.

Solved 489/1771 problems.




| # | Title | Solution | |---| ----- | -------- | |1897|Maximize Palindrome Length From Subsequences|| |1896|Maximum Score from Performing Multiplication Operations|| |1895|Minimum Number of Operations to Move All Balls to Each Box|| |1894|Merge Strings Alternately|| |1876|Map of Highest Peak|| |1875|Tree of Coprimes|| |1874|Form Array by Concatenating Subarrays of Another Array|| |916|Decoded String at Index|| |830|Largest Triangle Area|| |673|Number of Longest Increasing Subsequence|| |635|Design Log Storage System|| |634|Find the Derangement of An Array|| |633|Sum of Square Numbers|| |631|Design Excel Sum Formula|| |630|Course Schedule III|| |629|K Inverse Pairs Array|| |628|Maximum Product of Three Numbers|| |617|Merge Two Binary Trees|| |616|Add Bold Tag in String|| |611|Valid Triangle Number|| |604|Design Compressed String Iterator|| |600|Non-negative Integers without Consecutive Ones|| |599|Minimum Index Sum of Two Lists|| |598|Range Addition II|| |594|Longest Harmonious Subsequence|| |593|Valid Square|| |592|Fraction Addition and Subtraction|| |588|Design In-Memory File System|| |587|Erect the Fence|| |583|Delete Operation for Two Strings|| |582|Kill Process|| |581|Shortest Unsorted Continuous Subarray|| |575|Distribute Candies|| |565|Array Nesting|| |556|Next Greater Element III|| |553|Optimal Division|| |552|Student Attendance Record II|| |533|Lonely Pixel II|| |531|Lonely Pixel I|| |514|Freedom Trail|| |508|Most Frequent Subtree Sum|| |507|Perfect Number|| |504|Base 7|| |502|IPO|| |501|Find Mode in Binary Search Tree|| |500|Keyboard Row|| |495|Teemo Attacking|| |494|Target Sum|| |491|Increasing Subsequences|| |490|The Maze|| |485|Max Consecutive Ones|| |483|Smallest Good Base|| |482|License Key Formatting|| |481|Magical String|| |480|Sliding Window Median|| |477|Total Hamming Distance|| |476|Number Complement|| |475|Heaters|| |474|Ones and Zeroes|| |473|Matchsticks to Square|| |472|Concatenated Words|| |469|Convex Polygon|| |468|Validate IP Address|| |467|Unique Substrings in Wraparound String|| |466|Count The Repetitions|| |465|Optimal Account Balancing|| |464|Can I Win|| |463|Island Perimeter|| |462|Minimum Moves to Equal Array Elements II|| |461|Hamming Distance|| |459|Repeated Substring Pattern|| |456|132 Pattern|| |455|Assign Cookies|| |454|4Sum II|| |453|Minimum Moves to Equal Array Elements|| |452|Minimum Number of Arrows to Burst Balloons|| |447|Number of Boomerangs|| |446|Arithmetic Slices II - Subsequence|| |444|Sequence Reconstruction|| |441|Arranging Coins|| |440|K-th Smallest in Lexicographical Order|| |439|Ternary Expression Parser|| |438|Find All Anagrams in a String|| |437|Path Sum III|| |436|Find Right Interval|| |435|Non-overlapping Intervals|| |434|Number of Segments in a String|| |432|All O`one Data Structure|| |424|Longest Repeating Character Replacement|| |423|Reconstruct Original Digits from English|| |422|Valid Word Square|| |421|Maximum XOR of Two Numbers in an Array|| |420|Strong Password Checker|| |419|Battleships in a Board|| |417|Pacific Atlantic Water Flow|| |416|Partition Equal Subset Sum|| |415|Add Strings|| |414|Third Maximum Number|| |413|Arithmetic Slices|| |412|Fizz Buzz|| |410|Split Array Largest Sum|| |409|Longest Palindrome|| |408|Valid Word Abbreviation|| |407|Trapping Rain Water II|| |406|Queue Reconstruction by Height|| |405|Convert a Number to Hexadecimal|| |404|Sum of Left Leaves|| |403|Frog Jump|| |402|Remove K Digits|| |401|Binary Watch|| |400|Nth Digit|| |399|Evaluate Division|| |398|Random Pick Index|| |397|Integer Replacement|| |396|Rotate Function|| |395|Longest Substring with At Least K Repeating Characters|| |394|Decode String|| |393|UTF-8 Validation|| |392|Is Subsequence|| |391|Perfect Rectangle|| |390|Elimination Game|| |389|Find the Difference|| |388|Longest Absolute File Path|| |387|First Unique Character in a String|| |386|Lexicographical Numbers|| |385|Mini Parser|| |384|Shuffle an Array|| |383|Ransom Note|| |382|Linked List Random Node|| |381|Insert Delete GetRandom O(1) - Duplicates allowed|| |380|Insert Delete GetRandom O(1)|| |379|Design Phone Directory|| |378|Kth Smallest Element in a Sorted Matrix|| |377|Combination Sum IV|| |376|Wiggle Subsequence|| |375|Guess Number Higher or Lower II|| |374|Guess Number Higher or Lower|| |373|Find K Pairs with Smallest Sums|| |372|Super Pow|| |371|Sum of Two Integers|| |370|Range Addition|| |369|Plus One Linked List|| |368|Largest Divisible Subset|| |367|Valid Perfect Square|| |366|Find Leaves of Binary Tree|| |365|Water and Jug Problem|| |364|Nested List Weight Sum II|| |362|Design Hit Counter|| |361|Bomb Enemy|| |360|Sort Transformed Array|| |359|Logger Rate Limiter|| |358|Rearrange String k Distance Apart|| |357|Count Numbers with Unique Digits|| |356|Line Reflection|| |355|Design Twitter|| |354|Russian Doll Envelopes|| |353|Design Snake Game|| |352|Data Stream as Disjoint Intervals|| |351|Android Unlock Patterns|| |350|Intersection of Two Arrays II|| |349|Intersection of Two Arrays|| |348|Design Tic-Tac-Toe|| |347|Top K Frequent Elements|| |346|Moving Average from Data Stream|| |345|Reverse Vowels of a String|| |344|Reverse String|| |343|Integer Break|| |342|Power of Four|| |341|Flatten Nested List Iterator|| |340|Longest Substring with At Most K Distinct Characters|| |339|Nested List Weight Sum|| |338|Counting Bits|| |337|House Robber III|| |336|Palindrome Pairs|| |335|Self Crossing|| |334|Increasing Triplet Subsequence|| |333|Largest BST Subtree|| |332|Reconstruct Itinerary|| |331|Verify Preorder Serialization of a Binary Tree|| |330|Patching Array|| |329|Longest Increasing Path in a Matrix|| |328|Odd Even Linked List|| |327|Count of Range Sum|| |326|Power of Three|| |325|Maximum Size Subarray Sum Equals k|| |324|Wiggle Sort II|| |323|Number of Connected Components in an Undirected Graph|| |322|Coin Change|| |321|Create Maximum Number|| |320|Generalized Abbreviation|| |319|Bulb Switcher|| |318|Maximum Product of Word Lengths|| |317|Shortest Distance from All Buildings|| |316|Remove Duplicate Letters|| |315|Count of Smaller Numbers After Self|| |314|Binary Tree Vertical Order Traversal|| |313|Super Ugly Number|| |312|Burst Balloons|| |311|Sparse Matrix Multiplication|| |310|Minimum Height Trees|| |309|Best Time to Buy and Sell Stock with Cooldown|| |308|Range Sum Query 2D - Mutable|| |307|Range Sum Query - Mutable|| |306|Additive Number|| |305|Number of Islands II|| |304|Range Sum Query 2D - Immutable|| |303|Range Sum Query - Immutable|| |302|Smallest Rectangle Enclosing Black Pixels|| |301|Remove Invalid Parentheses|| |300|Longest Increasing Subsequence|| |299|Bulls and Cows|| |298|Binary Tree Longest Consecutive Sequence|| |297|Serialize and Deserialize Binary Tree|| |296|Best Meeting Point|| |295|Find Median from Data Stream|| |294|Flip Game II|| |293|Flip Game|| |292|Nim Game|| |291|Word Pattern II|| |290|Word Pattern|| |289|Game of Life|| |288|Unique Word Abbreviation|| |287|Find the Duplicate Number|| |286|Walls and Gates|| |285|Inorder Successor in BST|| |284|Peeking Iterator|| |283|Move Zeroes|| |282|Expression Add Operators|| |281|Zigzag Iterator|| |280|Wiggle Sort|| |279|Perfect Squares|| |278|First Bad Version|| |277|Find the Celebrity|| |276|Paint Fence|| |275|H-Index II|| |274|H-Index|| |273|Integer to English Words|| |272|Closest Binary Search Tree Value II|| |271|Encode and Decode Strings|| |270|Closest Binary Search Tree Value|| |269|Alien Dictionary|| |268|Missing Number|| |267|Palindrome Permutation II|| |266|Palindrome Permutation|| |265|Paint House II|| |264|Ugly Number II|| |263|Ugly Number|| |261|Graph Valid Tree|| |260|Single Number III|| |259|3Sum Smaller|| |258|Add Digits|| |257|Binary Tree Paths|| |256|Paint House|| |255|Verify Preorder Sequence in Binary Search Tree|| |254|Factor Combinations|| |253|Meeting Rooms II|| |252|Meeting Rooms|| |251|Flatten 2D Vector|| |250|Count Univalue Subtrees|| |249|Group Shifted Strings|| |248|Strobogrammatic Number III|| |247|Strobogrammatic Number II|| |246|Strobogrammatic Number|| |245|Shortest Word Distance III|| |244|Shortest Word Distance II|| |243|Shortest Word Distance|| |242|Valid Anagram|| |241|Different Ways to Add Parentheses|| |240|Search a 2D Matrix II|| |239|Sliding Window Maximum|| |238|Product of Array Except Self|| |237|Delete Node in a Linked List|| |236|Lowest Common Ancestor of a Binary Tree|| |235|Lowest Common Ancestor of a Binary Search Tree|| |234|Palindrome Linked List|| |233|Number of Digit One|| |232|Implement Queue using Stacks|| |231|Power of Two|| |230|Kth Smallest Element in a BST|| |229|Majority Element II|| |228|Summary Ranges|| |227|Basic Calculator II|| |226|Invert Binary Tree|| |225|Implement Stack using Queues|| |224|Basic Calculator|| |223|Rectangle Area|| |222|Count Complete Tree Nodes|| |221|Maximal Square|| |220|Contains Duplicate III|| |219|Contains Duplicate II|| |218|The Skyline Problem|| |217|Contains Duplicate|| |216|Combination Sum III|| |215|Kth Largest Element in an Array|| |214|Shortest Palindrome|| |213|House Robber II|| |212|Word Search II|| |210|Course Schedule II|| |209|Minimum Size Subarray Sum|| |208|Implement Trie (Prefix Tree)|| |207|Course Schedule|| |206|Reverse Linked List|| |205|Isomorphic Strings|| |204|Count Primes|| |203|Remove Linked List Elements|| |202|Happy Number|| |201|Bitwise AND of Numbers Range|| |200|Number of Islands|| |199|Binary Tree Right Side View|| |198|House Robber|| |191|Number of 1 Bits|| |190|Reverse Bits|| |189|Rotate Array|| |188|Best Time to Buy and Sell Stock IV|| |187|Repeated DNA Sequences|| |186|Reverse Words in a String II|| |179|Largest Number|| |174|Dungeon Game|| |173|Binary Search Tree Iterator|| |172|Factorial Trailing Zeroes|| |171|Excel Sheet Column Number|| |170|Two Sum III - Data structure design|| |169|Majority Element|| |168|Excel Sheet Column Title|| |167|Two Sum II - Input array is sorted|| |166|Fraction to Recurring Decimal|| |165|Compare Version Numbers|| |164|Maximum Gap|| |163|Missing Ranges|| |162|Find Peak Element|| |161|One Edit Distance|| |160|Intersection of Two Linked Lists|| |159|Longest Substring with At Most Two Distinct Characters|| |158|Read N Characters Given Read4 II - Call multiple times|| |157|Read N Characters Given Read4|| |156|Binary Tree Upside Down|| |155|Min Stack|| |154|Find Minimum in Rotated Sorted Array II|| |153|Find Minimum in Rotated Sorted Array|| |152|Maximum Product Subarray|| |151|Reverse Words in a String|| |150|Evaluate Reverse Polish Notation|| |149|Max Points on a Line|| |148|Sort List|| |147|Insertion Sort List|| |146|LRU Cache|| |145|Binary Tree Postorder Traversal|| |144|Binary Tree Preorder Traversal|| |143|Reorder List|| |142|Linked List Cycle II|| |141|Linked List Cycle|| |140|Word Break II|| |139|Word Break|| |138|Copy List with Random Pointer|| |137|Single Number II|| |136|Single Number|| |135|Candy|| |134|Gas Station|| |133|Clone Graph|| |132|Palindrome Partitioning II|| |131|Palindrome Partitioning|| |130|Surrounded Regions|| |129|Sum Root to Leaf Numbers|| |128|Longest Consecutive Sequence|| |127|Word Ladder|| |126|Word Ladder II|| |125|Valid Palindrome|| |124|Binary Tree Maximum Path Sum|| |123|Best Time to Buy and Sell Stock III|| |122|Best Time to Buy and Sell Stock II|| |121|Best Time to Buy and Sell Stock|| |120|Triangle|| |119|Pascal's Triangle II|| |118|Pascal's Triangle|| |117|Populating Next Right Pointers in Each Node II|| |116|Populating Next Right Pointers in Each Node|| |115|Distinct Subsequences|| |114|Flatten Binary Tree to Linked List|| |113|Path Sum II|| |112|Path Sum|| |111|Minimum Depth of Binary Tree|| |110|Balanced Binary Tree|| |109|Convert Sorted List to Binary Search Tree|| |108|Convert Sorted Array to Binary Search Tree|| |107|Binary Tree Level Order Traversal II|| |106|Construct Binary Tree from Inorder and Postorder Traversal|| |105|Construct Binary Tree from Preorder and Inorder Traversal|| |104|Maximum Depth of Binary Tree|| |103|Binary Tree Zigzag Level Order Traversal|| |102|Binary Tree Level Order Traversal|| |101|Symmetric Tree|| |100|Same Tree|| |99|Recover Binary Search Tree|| |98|Validate Binary Search Tree|| |97|Interleaving String|| |96|Unique Binary Search Trees|| |95|Unique Binary Search Trees II|| |94|Binary Tree Inorder Traversal|| |93|Restore IP Addresses|| |92|Reverse Linked List II|| |91|Decode Ways|| |90|Subsets II|| |89|Gray Code|| |88|Merge Sorted Array|| |87|Scramble String|| |86|Partition List|| |85|Maximal Rectangle|| |84|Largest Rectangle in Histogram|| |83|Remove Duplicates from Sorted List|| |82|Remove Duplicates from Sorted List II|| |81|Search in Rotated Sorted Array II|| |80|Remove Duplicates from Sorted Array II|| |79|Word Search|| |78|Subsets|| |77|Combinations|| |76|Minimum Window Substring|| |75|Sort Colors|| |74|Search a 2D Matrix|| |73|Set Matrix Zeroes|| |72|Edit Distance|| |71|Simplify Path|| |70|Climbing Stairs|| |69|Sqrt(x)|| |68|Text Justification|| |67|Add Binary|| |66|Plus One|| |65|Valid Number|| |64|Minimum Path Sum|| |63|Unique Paths II|| |62|Unique Paths|| |61|Rotate List|| |60|Permutation Sequence|| |59|Spiral Matrix II|| |58|Length of Last Word|| |57|Insert Interval|| |56|Merge Intervals|| |55|Jump Game|| |54|Spiral Matrix|| |53|Maximum Subarray|| |52|N-Queens II|| |51|N-Queens|| |50|Pow(x, n)|| |48|Rotate Image|| |47|Permutations II|| |46|Permutations|| |45|Jump Game II|| |44|Wildcard Matching|| |43|Multiply Strings|| |42|Trapping Rain Water|| |41|First Missing Positive|| |40|Combination Sum II|| |39|Combination Sum|| |38|Count and Say|| |37|Sudoku Solver|| |36|Valid Sudoku|| |35|Search Insert Position|| |33|Search in Rotated Sorted Array|| |32|Longest Valid Parentheses|| |31|Next Permutation|| |30|Substring with Concatenation of All Words|| |29|Divide Two Integers|| |28|Implement strStr()|| |27|Remove Element|| |26|Remove Duplicates from Sorted Array|| |25|Reverse Nodes in k-Group|| |24|Swap Nodes in Pairs|| |23|Merge k Sorted Lists|| |22|Generate Parentheses|| |21|Merge Two Sorted Lists|| |20|Valid Parentheses|| |19|Remove Nth Node From End of List|| |18|4Sum|| |17|Letter Combinations of a Phone Number|| |16|3Sum Closest|| |15|3Sum|| |14|Longest Common Prefix|| |13|Roman to Integer|| |12|Integer to Roman|| |11|Container With Most Water|| |10|Regular Expression Matching|| |9|Palindrome Number|| |8|String to Integer (atoi)|| |7|Reverse Integer|| |6|ZigZag Conversion|| |5|Longest Palindromic Substring|| |4|Median of Two Sorted Arrays|| |3|Longest Substring Without Repeating Characters|| |2|Add Two Numbers|| |1|Two Sum||

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.