### 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 #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

### Dynamic Programming

The idea behind solving dynamic programming problems is simple – remember what you have already solved and use the already computed solution in case you are solving the same problem again. In other words, solve one problem only once and remember the solution to it so that you can quickly provide the solution without the need to solve the problem again. … More Dynamic Programming

### Backtracking

Recursion makes exploration of all paths/branches of the tree very easy. At any time you only have to think about the current level and recursively call the function for exploring the children. Whenever you have a recursive code, you should always think about the base case where you will terminate the recursion. Depending on the problem it would, of course, differ. For the above example, the terminating condition can be “Is the current node the key?” … More Backtracking