### Leetcode 15. 3Sum

As we have already solved “Two Sum” problem already, let’s reuse our existing knowledge to solve this problem. We know the target and we want to search 3 numbers. We know how to search 2 numbers, so if we fix one number at a time and look for the other two numbers using our previous solution that would solve this problem as well.

Prefer video over text? Watch the explanation here: https://youtu.be/MmhfOzYMYPkMore Leetcode 15. 3Sum

### Leetcode 167. Two Sum II – Input array is sorted

What is the maximum possible sum of any two numbers from the array? It is sum of highest 2 numbers. Similarly, minimum sum is sum of lowest 2 numbers. Target is going to be somewhere in between these two numbers. What if we start in the middle? … More Leetcode 167. Two Sum II – Input array is sorted

### Leetcode 70. Climbing Stairs

Now that we know 3rd step can be reached directly from 1st and 2nd, what will be the number of ways in which we can reach the step 3? It would be all the ways in which we can reach the step 1 (because we can always take 2 steps from here to reach the step 3) + the number of ways in which we can reach the step 2 (because we can always take 1 more step to reach the step 3). … More Leetcode 70. Climbing Stairs

### Leetcode 1. Two Sum

once we fix one number, say K, then we know what the other number must be and i.e. target-K. For any other number, they won’t add up to the target. Now if we know that search is a vital operation, employ the best data structure for the search i.e. hash set. … More Leetcode 1. Two Sum

### Leetcode #1529: Bulb Switcher IV

Certainly, a “Flip” is a must when the current status of a bulb at index i and it’s the target status are not the same.

Initially all bulbs are OFF i.e. 0 and when a bulb at index i is flipped, every bulb after (in the right -> direction) that bulb gets flipped. So it only makes sense to start getting the status of the bulbs correct int the left to right order. … More Leetcode #1529: Bulb Switcher IV