LeetCode Solutions https://leetcode.com/problemset/algorithms/
| Problem | C/C++ | Java | Python3 |
|---|---|---|---|
| New Playgroundhaifengc Unique Morse Code Words | java | ||
| 01 Matrix | java | ||
| 1-bit and 2-bit Characters | java | ||
| 2 Keys Keyboard | java | ||
| 3Sum | cpp | java | |
| 3Sum Closest | cpp | ||
| 3Sum Smaller | cpp | java | |
| 4 Keys Keyboard | java | ||
| 4Sum | cpp | java | |
| 4Sum II | java | ||
| Accounts Merge | java | ||
| Add Binary | cpp | ||
| Add Bold Tag in String | java | ||
| Add Digits | cpp | ||
| Add One Row to Tree | java | ||
| Add Two Numbers | cpp | java | python |
| Add Two Numbers II | java | ||
| Add and Search Word - Data structure design | cpp | java | |
| Alien Dictionary | cpp | java | |
| All Paths From Source to Target | java | ||
| Android Unlock Patterns | java | ||
| Array Nesting | java | ||
| Array Partition I | java | ||
| Average of Levels in Binary Tree | java | ||
| Balanced Binary Tree | cpp | ||
| Base 7 | java | ||
| Basic Calculator | cpp | java | |
| Basic Calculator II | cpp | java | |
| Battleships in a Board | java | ||
| Best Meeting Point | cpp | ||
| Best Time to Buy and Sell Stock | cpp | java | |
| Best Time to Buy and Sell Stock II | cpp | java | |
| Best Time to Buy and Sell Stock with Cooldown | java | ||
| Binary Number with Alternating Bits | java | ||
| Binary Search Tree Iterator | cpp | java | |
| Binary Tree Inorder Traversal | cpp | java | |
| Binary Tree Level Order Traversal | cpp | ||
| Binary Tree Level Order Traversal II | cpp | ||
| Binary Tree Longest Consecutive Sequence | cpp | java | |
| Binary Tree Longest Consecutive Sequence II | java | ||
| Binary Tree Maximum Path Sum | cpp | java | |
| Binary Tree Paths | cpp | ||
| Binary Tree Postorder Traversal | cpp | ||
| Binary Tree Preorder Traversal | cpp | ||
| Binary Tree Right Side View | cpp | ||
| Binary Tree Tilt | java | ||
| Binary Tree Upside Down | cpp | ||
| Binary Tree Upside Down.c | cpp | ||
| Binary Tree Vertical Order Traversal | java | ||
| Binary Tree Zigzag Level Order Traversal | cpp | ||
| Binary Watch | java | ||
| Bitwise AND of Numbers Range | cpp | ||
| Bold Words in String | java | ||
| Boundary of Binary Tree | java | ||
| Bulb Switcher | cpp | ||
| Bulls and Cows | cpp | ||
| Can Place Flowers | java | ||
| Candy | cpp | ||
| Champagne Tower | java | ||
| Climbing Stairs | cpp | java | |
| Clone Graph | cpp | java | |
| Closest Binary Search Tree Value | cpp | java | |
| Closest Binary Search Tree Value II | cpp | ||
| Closest Leaf in a Binary Tree | java | ||
| Coin Change | cpp | java | |
| Coin Change 2 | java | ||
| Coin Path | java | ||
| Combination Sum | cpp | ||
| Combination Sum II | cpp | ||
| Combination Sum III | cpp | ||
| Combinations | cpp | ||
| Compare Version Numbers | cpp | ||
| Complex Number Multiplication | java | ||
| Construct Binary Tree from Inorder and Postorder Traversal | cpp | ||
| Construct Binary Tree from Preorder and Inorder Traversal | cpp | ||
| Construct Binary Tree from String | java | ||
| Construct String from Binary Tree | java | ||
| Container With Most Water | cpp | java | |
| Contains Duplicate | cpp | java | |
| Contains Duplicate II | cpp | java | |
| Contains Duplicate III | cpp | java | |
| Contiguous Array | java | ||
| Continuous Subarray Sum | java | ||
| Convert Sorted Array to Binary Search Tree | cpp | java | |
| Convert Sorted List to Binary Search Tree | cpp | java | |
| Copy List with Random Pointer | java | ||
| Count Complete Tree Nodes | cpp | ||
| Count Numbers with Unique Digits | cpp | ||
| Count Primes | cpp | java | |
| Count Univalue Subtrees | cpp | ||
| Count and Say | cpp | java | |
| Count of Range Sum | java | ||
| Count of Smaller Numbers After Self | cpp | java | |
| Counting Bits | java | ||
| Couples Holding Hands | java | ||
| Course Schedule | cpp | java | |
| Course Schedule II | cpp | ||
| Course Schedule III | java | ||
| Custom Sort String | java | ||
| Cut Off Trees for Golf Event | java | ||
| Daily Temperatures | java | ||
| Decode Ways | cpp | ||
| Decode Ways II | java | ||
| Delete Node in a Linked List | cpp | java | |
| Delete Operation for Two Strings | java | ||
| Design Compressed String Iterator | java | ||
| Design Excel Sum Formula | java | ||
| Design In-Memory File System | java | ||
| Design Log Storage System | java | ||
| Design Phone Directory | java | ||
| Design Search Autocomplete System | java | ||
| Design Snake Game | java | ||
| Design Tic-Tac-Toe | java | ||
| Diagonal Traverse | java | ||
| Diameter of Binary Tree | java | ||
| Distinct Subsequences | cpp | ||
| Distribute Candies | java | ||
| Divide Two Integers | cpp | java | |
| Dota2 Senate | java | ||
| Edit Distance | cpp | ||
| Employee Free Time | java | ||
| Employee Importance | java | ||
| Encode and Decode Strings | cpp | java | |
| Encode and Decode TinyURL | java | ||
| Erect the Fence | java | ||
| Escape The Ghosts | java | ||
| Evaluate Reverse Polish Notation | cpp | ||
| Excel Sheet Column Number | cpp | java | |
| Excel Sheet Column Title | cpp | java | |
| Exclusive Time of Functions | java | ||
| Expression Add Operators | java | ||
| Expressive Words | java | ||
| Factor Combinations | cpp | java | |
| Factorial Trailing Zeroes | cpp | java | |
| Find Anagram Mappings | java | ||
| Find Duplicate File in System | java | ||
| Find Duplicate Subtrees | java | ||
| Find Eventual Safe States | java | ||
| Find K Closest Elements | java | ||
| Find K Pairs with Smallest Sums | java | ||
| Find K-th Smallest Pair Distance | java | ||
| Find Median from Data Stream | cpp | java | |
| Find Minimum in Rotated Sorted Array | cpp | java | |
| Find Minimum in Rotated Sorted Array II | cpp | java | |
| Find Peak Element | cpp | ||
| Find Permutation | java | ||
| Find Smallest Letter Greater Than Target | java | ||
| Find the Celebrity | cpp | java | |
| Find the Derangement of An Array | java | ||
| Find the Difference | java | ||
| Find the Duplicate Number | cpp | ||
| First Bad Version | cpp | ||
| First Bad Version.c | cpp | ||
| First Missing Positive | cpp | java | |
| First Unique Character in a String | java | ||
| Fizz Buzz | java | ||
| Flatten 2D Vector | cpp | java | |
| Flatten Binary Tree to Linked List | cpp | java | |
| Flatten Nested List Iterator | java | ||
| Flip Game | cpp | ||
| Flip Game II | cpp | ||
| Fraction Addition and Subtraction | java | ||
| Fraction to Recurring Decimal | cpp | java | |
| Game of Life | cpp | java | |
| Gas Station | cpp | ||
| Generate Parentheses | cpp | java | |
| Global and Local Inversions | java | ||
| Graph Valid Tree | cpp | java | |
| Group Anagrams | cpp | java | |
| Group Shifted Strings | cpp | java | |
| H-Index | cpp | java | |
| H-Index II | cpp | java | |
| Hamming Distance | java | ||
| Happy Number | cpp | java | |
| House Robber | cpp | java | |
| House Robber II | cpp | java | |
| House Robber III | cpp | java | |
| IPO | java | ||
| Implement Magic Dictionary | java | ||
| Implement Queue using Stacks | cpp | ||
| Implement Stack using Queues | cpp | ||
| Implement Trie (Prefix Tree) | cpp | java | |
| Implement strStr() | cpp | java | |
| Inorder Successor in BST | cpp | java | |
| Insert Delete GetRandom O(1) | java | ||
| Insert Delete GetRandom O(1) - Duplicates allowed | java | ||
| Insert Interval | cpp | ||
| Insertion Sort List | cpp | ||
| Integer to English Words | cpp | java | |
| Integer to Roman | cpp | ||
| Interleaving String | cpp | ||
| Intersection of Two Arrays | java | ||
| Intersection of Two Arrays II | java | ||
| Intersection of Two Linked Lists | cpp | java | |
| Invert Binary Tree | cpp | ||
| Is Graph Bipartite | java | ||
| Island Perimeter | java | ||
| Isomorphic Strings | cpp | ||
| Jewels and Stones | java | ||
| Judge Route Circle | java | ||
| Jump Game | cpp | ||
| Jump Game II | cpp | ||
| K Empty Slots | java | ||
| K Inverse Pairs Array | java | ||
| K-th Smallest Prime Fraction | java | ||
| Kill Process | java | ||
| Knight Probability in Chessboard | java | ||
| Kth Largest Element in an Array | cpp | java | |
| Kth Smallest Element in a BST | cpp | java | |
| Kth Smallest Element in a Sorted Matrix | java | ||
| LFU Cache | java | ||
| LRU Cache | cpp | java | |
| Largest BST Subtree | cpp | ||
| Largest Number | cpp | ||
| Largest Plus Sign | java | ||
| Largest Rectangle in Histogram | cpp | ||
| Length of Last Word | cpp | ||
| Letter Case Permutation | java | ||
| Letter Combinations of a Phone Number | cpp | java | |
| License Key Formatting | java | ||
| Linked List Cycle | cpp | java | |
| Logger Rate Limiter | java | ||
| Longest Common Prefix | cpp | java | |
| Longest Consecutive Sequence | cpp | java | |
| Longest Continuous Increasing Subsequence | java | ||
| Longest Harmonious Subsequence | java | ||
| Longest Increasing Path in a Matrix | cpp | ||
| Longest Increasing Subsequence | cpp | ||
| Longest Palindromic Subsequence | java | ||
| Longest Palindromic Substring | cpp | java | |
| Longest Substring Without Repeating Characters | cpp | java | |
| Longest Substring with At Least K Repeating Characters | java | ||
| Longest Substring with At Most K Distinct Characters | java | ||
| Longest Substring with At Most Two Distinct Characters | cpp | ||
| Longest Univalue Path | java | ||
| Longest Valid Parentheses | cpp | ||
| Lowest Common Ancestor of a Binary Search Tree | cpp | ||
| Lowest Common Ancestor of a Binary Tree | cpp | java | |
| Magical String | java | ||
| Majority Element | cpp | java | |
| Majority Element II | cpp | ||
| Map Sum Pairs | java | ||
| Matchsticks to Square | java | ||
| Max Area of Island | java | ||
| Max Chunks To Make Sorted (ver. 1) | java | ||
| Max Chunks to Make Sorted (ver. 2) | java | ||
| Max Consecutive Ones II | java | ||
| Max Increase to Keep City Skyline | java | ||
| Max Points on a Line | cpp | ||
| Maximal Rectangle | cpp | ||
| Maximal Square | cpp | ||
| Maximum Average Subarray I | java | ||
| Maximum Average Subarray II | java | ||
| Maximum Binary Tree | java | ||
| Maximum Depth of Binary Tree | cpp | java | |
| Maximum Distance in Arrays | java | ||
| Maximum Length of Pair Chain | java | ||
| Maximum Length of Repeated Subarray | java | ||
| Maximum Product Subarray | cpp | java | |
| Maximum Product of Three Numbers | java | ||
| Maximum Product of Word Lengths | java | ||
| Maximum Size Subarray Sum Equals k | cpp | ||
| Maximum Subarray | cpp | java | |
| Maximum Vacation Days | java | ||
| Median of Two Sorted Arrays | cpp | java | |
| Meeting Rooms | cpp | java | |
| Meeting Rooms II | cpp | java | |
| Merge Intervals | cpp | ||
| Merge Sorted Array | cpp | java | |
| Merge Two Binary Trees | java | ||
| Merge Two Sorted Lists | cpp | java | |
| Merge k Sorted Lists | cpp | java | |
| Min Cost Climbing Stairs | java | ||
| Min Stack | cpp | java | |
| Minesweeper | java | ||
| Minimize Max Distance to Gas Station | java | ||
| Minimum ASCII Delete Sum for Two Strings | java | ||
| Minimum Depth of Binary Tree | cpp | ||
| Minimum Distance Between BST Nodes | java | ||
| Minimum Factorization | java | ||
| Minimum Genetic Mutation | cpp | ||
| Minimum Index Sum of Two Lists | java | ||
| Minimum Number of Arrows to Burst Balloons | java | ||
| Minimum Path Sum | cpp | ||
| Minimum Size Subarray Sum | cpp | ||
| Minimum Time Difference | java | ||
| Minimum Unique Word Abbreviation | java | ||
| Minimum Window Substring | cpp | ||
| Missing Number | cpp | java | |
| Missing Ranges | cpp | ||
| Monotone Increasing Digits | java | ||
| Move Zeroes | cpp | java | |
| Moving Average from Data Stream | java | ||
| Multiply Strings | cpp | java | |
| N-Queens | cpp | ||
| N-Queens II | cpp | ||
| Nested List Weight Sum | java | ||
| Nested List Weight Sum II | java | ||
| Network Delay Time | java | ||
| Next Closest Time | java | ||
| Next Greater Element III | java | ||
| Next Permutation | cpp | ||
| Nim Game | cpp | java | |
| Non-negative Integers without Consecutive Ones | java | ||
| Nth Digit | java | ||
| Number Of Corner Rectangles | java | ||
| Number of 1 Bits | cpp | java | |
| Number of Connected Components in an Undirected Graph | cpp | ||
| Number of Distinct Islands | java | ||
| Number of Islands | cpp | ||
| Number of Islands II | cpp | java | |
| Number of Lines To Write String | java | ||
| Number of Longest Increasing Subsequence | java | ||
| Number of Matching Subsequences | java | ||
| Number of Subarrays with Bounded Maximum | java | ||
| Odd Even Linked List | cpp | java | |
| One Edit Distance | cpp | java | |
| Open the Lock | java | ||
| Optimal Account Balancing | java | ||
| Out of Boundary Paths | java | ||
| Output Contest Matches | java | ||
| Paint Fence | cpp | java | |
| Paint House | cpp | java | |
| Paint House II | cpp | java | |
| Palindrome Linked List | cpp | java | |
| Palindrome Number | cpp | java | |
| Palindrome Pairs | cpp | ||
| Palindrome Partitioning | cpp | ||
| Palindrome Partitioning II | cpp | ||
| Palindrome Permutation | cpp | java | |
| Palindrome Permutation II | cpp | ||
| Palindromic Substrings | java | ||
| Partition Labels | java | ||
| Partition List | cpp | java | |
| Pascal's Triangle | cpp | java | |
| Pascal's Triangle II | cpp | ||
| Path Sum | cpp | ||
| Path Sum II | cpp | ||
| Peeking Iterator | cpp | java | |
| Perfect Number | java | ||
| Perfect Rectangle | java | ||
| Perfect Squares | cpp | ||
| Permutation Sequence | cpp | ||
| Permutation in String | java | ||
| Permutations | cpp | java | |
| Permutations II | cpp | ||
| Plus One | cpp | java | |
| Plus One Linked List | java | ||
| Populating Next Right Pointers in Each Node | cpp | java | |
| Populating Next Right Pointers in Each Node II | cpp | java | |
| Pow(x, n) | cpp | java | |
| Power of Three | cpp | java | |
| Power of Two | cpp | ||
| Preimage Size of Factorial Zeroes Function | java | ||
| Prime Number of Set Bits in Binary Representation | java | ||
| Print Binary Tree | java | ||
| Product of Array Except Self | cpp | java | |
| Rabbits in Forest | java | ||
| Random Pick Index | java | ||
| Range Addition II | java | ||
| Range Sum Query - Immutable | cpp | ||
| Range Sum Query - Mutable | cpp | ||
| Range Sum Query 2D - Immutable | cpp | ||
| Range Sum Query 2D - Mutable | java | ||
| Read N Characters Given Read4 | cpp | java | |
| Read N Characters Given Read4 II - Call multiple times | cpp | java | |
| Rectangle Area | cpp | ||
| Redundant Connection | java | ||
| Regular Expression Matching | cpp | java | |
| Remove 9 | java | ||
| Remove Duplicates from Sorted Array | cpp | java | |
| Remove Duplicates from Sorted Array II | cpp | ||
| Remove Duplicates from Sorted List | cpp | java | |
| Remove Duplicates from Sorted List II | cpp | ||
| Remove Element | cpp | java | |
| Remove Invalid Parentheses | cpp | java | |
| Remove Linked List Elements | cpp | java | |
| Remove Nth Node From End of List | cpp | ||
| Reorder List | cpp | java | |
| Reorganize String | java | ||
| Repeated DNA Sequences | cpp | ||
| Repeated String Match | java | ||
| Replace Words | java | ||
| Reshape the Matrix | java | ||
| Restore IP Addresses | java | ||
| Reverse Bits | cpp | java | |
| Reverse Integer | cpp | java | |
| Reverse Linked List | cpp | java | |
| Reverse Linked List II | cpp | java | |
| Reverse Nodes in k-Group | cpp | java | |
| Reverse Pairs | java | ||
| Reverse String | java | ||
| Reverse String II | java | ||
| Reverse Words in a String | cpp | ||
| Reverse Words in a String II | cpp | ||
| Roman to Integer | cpp | java | |
| Rotate Array | cpp | java | |
| Rotate Image | cpp | ||
| Rotate List | cpp | java | |
| Rotate String | java | ||
| Rotated Digits | java | ||
| Russian Doll Envelopes | java | ||
| Same Tree | cpp | ||
| Search Insert Position | cpp | ||
| Search a 2D Matrix | cpp | java | |
| Search a 2D Matrix II | cpp | java | |
| Search for a Range | cpp | java | |
| Search in Rotated Sorted Array | cpp | java | |
| Search in Rotated Sorted Array II | cpp | java | |
| Serialize and Deserialize BST | java | ||
| Serialize and Deserialize Binary Tree | cpp | java | |
| Set Matrix Zeroes | cpp | ||
| Set Mismatch | java | ||
| Shopping Offers | java | ||
| Shortest Completing Word | java | ||
| Shortest Distance from All Buildings | java | ||
| Shortest Unsorted Continuous Subarray | java | ||
| Shortest Word Distance | cpp | ||
| Shortest Word Distance II | cpp | ||
| Shortest Word Distance III | cpp | ||
| Shuffle an Array | java | ||
| Similar RGB Color | java | ||
| Simplify Path | cpp | java | |
| Single Number | java | python | |
| Single Number II | cpp | ||
| Single Number III | cpp | ||
| Sliding Puzzle | java | ||
| Sliding Window Median | java | ||
| Smallest Range | java | ||
| Smallest Rectangle Enclosing Black Pixels | cpp | java | |
| Solve the Equation | java | ||
| Sort Colors | cpp | ||
| Sort List | cpp | java | |
| Sort Transformed Array | java | ||
| Soup Servings | java | ||
| Spiral Matrix | cpp | java | |
| Spiral Matrix II | cpp | ||
| Split Array into Consecutive Subsequences | java | ||
| Sqrt(x) | cpp | java | |
| Squirrel Simulation | java | ||
| String Compression | java | ||
| String to Integer (atoi) | java | ||
| Strobogrammatic Number | cpp | ||
| Strobogrammatic Number II | cpp | ||
| Student Attendance Record II | java | ||
| Subarray Sum Equals K | java | ||
| Subdomain Visit Count | java | ||
| Subsets | cpp | ||
| Subsets II | cpp | ||
| Substring with Concatenation of All Words | cpp | ||
| Subtree of Another Tree | java | ||
| Sudoku Solver | cpp | java | |
| Sum Root to Leaf Numbers | cpp | ||
| Sum of Square Numbers | java | ||
| Sum of Two Integers | java | ||
| Summary Ranges | cpp | ||
| Surrounded Regions | cpp | ||
| Swap Nodes in Pairs | cpp | java | |
| Swim in Rising Water | java | ||
| Symmetric Tree | cpp | java | |
| Tag Validator | java | ||
| Task Scheduler | java | ||
| The Maze | java | ||
| The Skyline Problem | cpp | ||
| Toeplitz Matrix | java | ||
| Top K Frequent Elements | java | ||
| Top K Frequent Words | java | ||
| Trapping Rain Water | cpp | java | |
| Triangle | cpp | ||
| Two Sum | cpp | java | |
| Two Sum II - Input array is sorted | cpp | java | |
| Two Sum III - Data structure design | cpp | java | |
| Two Sum IV - Input is a BST | java | ||
| Ugly Number | cpp | python | |
| Ugly Number II | cpp | ||
| Unique Binary Search Trees | cpp | java | |
| Unique Binary Search Trees II | cpp | ||
| Unique Paths | cpp | java | |
| Unique Paths II | cpp | ||
| Unique Word Abbreviation | cpp | ||
| Valid Anagram | cpp | java | |
| Valid Palindrome | cpp | java | |
| Valid Palindrome II | java | ||
| Valid Parentheses | cpp | java | |
| Valid Parenthesis String | java | ||
| Valid Square | java | ||
| Valid Sudoku | cpp | java | |
| Valid Tic-Tac-Toe State | java | ||
| Valid Triangle Number | java | ||
| Validate Binary Search Tree | cpp | java | |
| Verify Preorder Serialization of a Binary Tree | cpp | java | |
| Walls and Gates | cpp | ||
| Wiggle Sort | cpp | java | |
| Wildcard Matching | cpp | java | |
| Word Abbreviation | java | ||
| Word Break | cpp | ||
| Word Break II | cpp | ||
| Word Ladder | cpp | ||
| Word Ladder II | cpp | ||
| Word Pattern | cpp | ||
| Word Pattern II | cpp | ||
| Word Search | cpp | ||
| Word Search II | cpp | ||
| Word Squares | java | ||
| Zigzag Iterator | cpp | ||
| ceilFloorIndex | java |