Leetcode 42: Trapping Rain Water: From Brute Force to Optimal Two Pointers
The Trapping Rain Water problem is an excellent example of how understanding the properties of a problem can lead to significant optimizations. The biggest takeaway is recognizing that the smaller of the two maximum boundaries determines the water level.
Leetcode 15: 3Sum – From Brute Force to Two Pointers
The key insight is realizing that after sorting the array, we don’t need three nested loops anymore. Instead: Fix one number., use two pointers to search for the other two, skip duplicates carefully and stop early once the fixed number becomes positive.
Leetcode 1: Two Sum Explained: From Brute Force to an Optimal Hash Map Solution
The Two Sum problem is one of the most popular coding interview questions. Although it looks simple, it introduces several important concepts that appear repeatedly in algorithm design, such as brute force search, sorting with two pointers, and hash maps.
Solution: Leetcode 26 Removing Duplicates from Sorted Array in Python
The problem at hand is to remove duplicates from a sorted integer array nums in-place, such that each unique element appears only once. Additionally, we need to return the number of unique elements present in the modified array.
Solution: LeetCode 88 Merge Sorted Array
You are given two integer arrays nums1 and nums2, sorted in non-decreasing order, and two integers m and n, representing the number of elements in nums1 and nums2 respectively. Merge nums1 and nums2 into a single array sorted in non-decreasing order.
