## Leetcode – 64. Minimum Path Sum

There were two approaches that came to my mind when I first read this problem. This is a classic recursion problem and we can use a a modified DFS approach checking at each point if we can move left and down and then recurse from the new positions. The time complexity of this would be exponential of the order of …

Leetcode – 64. Minimum Path Sum

## Leetcode – 79. Word Search

In this problem, we are given a two dimensional board of characters and we have to check if the word can be found in the board by checking adjacent cells only. A basic strategy to solve this problem would be to start walking down the board until the first character is found. Once the first character is found, look at …

Leetcode – 79. Word Search

## Leetcode – 33. Search In Rotated Sorted Array

This is straight up Binary Search problem with some modifications. When we find the mid point of the given array, one of two things will hold true: The array from start to mid is sorted. The array from mid to end is sorted. Once we know which is the sorted half, all we have to do is check if the …

Leetcode – 33. Search In Rotated Sorted Array

## Leetcode – 42. Trapping Rain Water

There’s one thing common between this problem and the Container With Most Water problem and that is the height of the shorter tower dictates the result. In this problem, the amount of water that can accumulate between two towers is limited by the height of the shorter tower.  Consider an array [4, 5, 9, 7 ,1, 0 ,4, 0 ,8 …

Leetcode – 42. Trapping Rain Water

## Leetcode – 54. Spiral Matrix

The first idea that popped in my head after reading this problem is to start at index [0,0] and move right, walk down all the columns, turn right, walk down all the rows, move right, walk down all the columns in decreasing order, move right, walk up all the rows in decreasing order. At this point, how do we keep …

Leetcode – 54. Spiral Matrix

## Leetcode – 11. Container With Most Water

From the description of the problem, we are told that each number in the array represents the height of the vertical line at that index. So given an array [4, 3, 7, 8, 2, 6, 9, 5], a visual representation of this array would look something like: | | | | | | | | | | | | | …

Leetcode – 11. Container With Most Water