Microsoft | Online | Unique paths

Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2023-12-14Added By Anonymous
Source: Link

Hello LeetCode community,


I recently had an interview with Microsoft during the onsite round, and I encountered an interesting problem related to dynamic programming. I wanted to share it with you all and get your insights.


Problem Description:

You are given a 2D grid representing a m x n grid. The grid has obstacles, indicated by 1s, and empty cells, indicated by 0s. Your goal is to find the number of unique paths from the top-left corner to the bottom-right corner, while only moving right or down.


Example:

Input:

[

[0,0,0],

[0,1,0],

[0,0,0]

]

Output: 2

Explanation: There are two unique paths to reach the bottom-right corner.


1.Right -> Right -> Down -> Down
2.Down -> Down -> Right -> Right


Please share your thoughts on how you would approach this problem and if you've seen a similar question in other interviews. Your insights are much appreciated!

Happy coding! 😊

Comments