Skip to content

Commit 3dac5aa

Browse files
committed
Improve: More comments added for better understanding
1 parent e1c8bd1 commit 3dac5aa

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

Dynamic-Programming/UniquePaths.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
1-
/**
1+
/*
22
* A Dynamic Programming based solution for calculating the number ways to travel from Top-Left of the matrix to Bottom-Right of the matrix
33
* https://leetcode.com/problems/unique-paths/
4+
* Problem Statement:
5+
* There is a robot on an m x n grid. The robot is initially located at the top-left corner (i.e., grid[0][0]). The robot tries to move to the bottom-right corner (i.e., grid[m - 1][n - 1]). The robot can only move either down or right at any point in time.
6+
* Given the two integers m and n, return the number of possible unique paths that the robot can take to reach the bottom-right corner.
7+
* Approach:
8+
* As the given problem can be reduced to smaller and overlapping sub problems, we can use dynamic programming and memoization to solve this problem.
9+
* Time complexity: O(M * N) (M->ROWS | N->COLS)
10+
* Space complexity: O(M * N) (M->ROWS | N->COLS)
11+
*/
12+
13+
/**
14+
* @param {number} rows
15+
* @param {number} cols
16+
* @return {number}
417
*/
518

619
// Return the number of unique paths, given the dimensions of rows and columns

0 commit comments

Comments
 (0)