LeetCode Problem Solutions in C++
Welcome to my LeetCode problem solutions repository! ๐ Here, you'll find C++ solutions to a variety of interesting problems across different categories. Feel free to explore and learn from these solutions as you tackle your own LeetCode challenges. If you find this repository helpful, please consider giving it a โญ๏ธ!
Problems
Binary Search ๐:
- Search Insert Position
- Search a 2D Matrix
- Search a 2D Matrix II
- Find Peak Element
- Search in Rotated Sorted Array
- Find First and Last Position of Element in Sorted Array
- Find Minimum in Rotated Sorted Array
- Median of Two Sorted Arrays
- Ways to Split Array Into Three Subarrays
Dynamic Programming ๐งฎ:
- Climbing Stairs
- House Robber
- Word Break
- All Possible Full Binary Trees
- Get Maximum in Generated Array
- N-th Tribonacci Number
- Longest Increasing Subsequence
- Coin Change
- Partition Array for Maximum Sum
- Egg Drop With 2 Eggs and N Floors
- Count Substrings That Differ by One Character
- Fair Distribution of Cookies
- Stone Game II
- Palindromic Substrings
- Longest ZigZag Path in a Binary Tree
- Longest Subarray of 1's After Deleting One Element
- Palindrome Partitioning
- Minimum Path Cost in a Grid
- Minimum Falling Path Sum
- Minimum Cost For Tickets
- Arithmetic Slices
- Minimum ASCII Delete Sum for Two Strings
- Minimum ASCII Delete Sum for Two Strings
- Beautiful Arrangement Solution
- Ways to Make a Fair Array
- Uncrossed Lines
- Longest Palindromic Subsequence
- Maximum Compatibility Score Sum
- Flip String to Monotone Increasing Solution
- Different Ways to Add Parentheses Solution
- Delete Operation for Two Strings
- Longest String Chain
- Unique Binary Search Trees
- Integer Break
- Maximum Sum of Two Non-Overlapping Subarrays
- Filling Bookcase Shelves
- Best Sightseeing Pair
- Maximum Alternating Subsequence Sum
- Maximum Absolute Sum of Any Subarray
- Minimum Deletions to Make String Balanced
- Number of Smooth Descent Periods of a Stock
- Make Costs of Paths Equal in a Binary Tree
- Find the City With the Smallest Number of Neighbors at a Threshold Distance
- Stone Game VII
- Longest Common Subsequence
- Shortest Common Supersequence
- Best Time to Buy and Sell Stock
- Best Time to Buy and Sell Stock II
- Best Time to Buy and Sell Stock with Cooldown
- Best Time to Buy and Sell Stock III
- Best Time to Buy and Sell Stock IV
- Edit Distance
- Find the Substring With Maximum Cost
- Unique Binary Search Trees II
- Delete and Earn
- Predict the Winner
- Count Ways To Build Good Strings
- Solving Questions With Brainpower
- Last Stone Weight II
- Vowels of All Substrings
- House Robber III
- House Robber II
- Combination Sum IV
- Largest Sum of Averages
- Jump Game
- Interleaving String
- Jump Game VI
- Binary Trees With Factors
- Extra Characters in a String
- Partition String Into Minimum Beautiful Substrings
- Domino and Tromino Tiling
- Video Stitching
- Maximum Length of Repeated Subarray
- Greatest Sum Divisible by Three
Heap ๐:
- Kth Largest Element in an Array
- IPO
- Find K Pairs with Smallest Sums
- Find Median from Data Stream
- Minimum Cost to Hire K Workers
- Find the Kth Smallest Sum of a Matrix With Sorted Rows
- Sliding Window Maximum
Stack ๐ฅ:
- Largest Rectangle in Histogram
- Count Submatrices With All Ones
Greedy ๐ฐ:
- Longest Unequal Adjacent Groups Subsequence I
- Largest Values From Labels
- Reducing Dishes
BFS & DFS ๐:
- Push Dominoes
- K-Similar Strings
- Recover a Tree From Preorder Traversal
- As Far from Land as Possible
Math โพ๏ธ:
- Maximum of Absolute Value Expression
Data Structures ๐๏ธ:
- Insert Delete GetRandom O(1)
LinkedLists ๐:
- Remove Nth Node From End of List
Graphs:
- Evaluate Division
- All Elements in Two Binary Search Trees
- Course Schedule
- Course Schedule II
- Binary Tree Maximum Path Sum
- Cheapest Flights Within K Stops
- Binary Tree Coloring Game
Arrays ๐:
- Number of Ways to Split Array
- Sort Array By Parity II
- Distance Between Bus Stops
- Find the Highest Altitude
Other:
- Toeplitz Matrix
- Bulls and Cows
- Brace Expansion II Solution
- Unique Paths III
- Max Increase to Keep City Skyline
- Set Matrix Zeroes ๐คข (genuinely hate this problem)
- Battleships in a Board
- Binary String With Substrings Representing 1 To N
- Candy
- Restore IP Addresses
- Minimum Time to Make Rope Colorful
- Pow(x, n)
- Partition Array into Disjoint Intervals
- Brick Wall
- Array Nesting
- Minimum Number of Steps to Make Two Strings Anagram II
- Remove Letter To Equalize Frequency
- Find the Town Judge
- Shopping Offers
- Check if There is a Valid Partition For The Array
- Number of Matching Subsequences
Happy coding! If you have any questions or suggestions, feel free to open an issue or create a pull request.
๐ Happy Learning! ๐