From 0db20da3438a79b72223fe5c1e5d3bea403c18fd Mon Sep 17 00:00:00 2001 From: Yash Khandelwal <68386161+yash2040@users.noreply.github.com> Date: Thu, 22 Oct 2020 12:53:42 +0530 Subject: [PATCH 1/2] Create 0062.cpp --- C++/0062.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 C++/0062.cpp diff --git a/C++/0062.cpp b/C++/0062.cpp new file mode 100644 index 0000000..4faa8b5 --- /dev/null +++ b/C++/0062.cpp @@ -0,0 +1,12 @@ +class Solution { +public: + int uniquePaths(int m, int n) { + vector> dp(m, vector(n, 1)); + for (int i = 1; i < m; i++) { + for (int j = 1; j < n; j++) { + dp[i][j] = dp[i - 1][j] + dp[i][j - 1]; + } + } + return dp[m - 1][n - 1]; + } +}; From 85836347d863d936d22bfc929aebd129764d1b14 Mon Sep 17 00:00:00 2001 From: Yash Khandelwal <68386161+yash2040@users.noreply.github.com> Date: Thu, 22 Oct 2020 13:04:43 +0530 Subject: [PATCH 2/2] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 46d3d80..0bac074 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Or from the Sheet 1 of this [Google Sheet](https://bit.ly/2EUhwnw) | 0045 | [Jump Game II](https://leetcode.com/problems/jump-game-ii/) | newEnd = max(newEnd, i+nums[i]) | [C++](https://github.com/sankalpdayal5/LeetCode-Solutions/blob/master/C++/0045.cpp) | O(n) | O(1) | Hard | Array Greedy | [📺](https://www.youtube.com/watch?v=hJ8EMc24O_M) | | 0053 | [Maximum Subarray](https://leetcode.com/problems/maximum-subarray/) | Parse array and save the best solution at each step | [Java](https://github.com/sankalpdayal5/LeetCode-Solutions/blob/master/Java/0053.java) [Python](https://github.com/sankalpdayal5/LeetCode-Solutions/blob/master/Python/0053.py) | O(n) | O(1) | Easy | Array Dynamic Programming | [📺](https://www.youtube.com/watch?v=vkLpz2YF8Rc) | | 0055 | [Jump Game](https://leetcode.com/problems/jump-game/) | Iterate from last index and check if we can reach there from current index or not | [Python](https://github.com/sankalpdayal5/LeetCode-Solutions/blob/master/Python/0055.py) | O(n) | O(1) | Medium | Array Greedy | [📺](https://www.youtube.com/watch?v=ymET7SJsDQc) | -| 0062| [Unique Paths (Total no of unique paths in m x n matrix)](https://leetcode.com/problems/unique-paths/) | As the first element in each row will always be 1, so maintaining one row is enough to reach bottom-right corner of the grid | [Java]() | O(n) | O(1) | Medium |Array Dynamic Programming | | +| 0062| [Unique Paths (Total no of unique paths in m x n matrix)](https://leetcode.com/problems/unique-paths/) | As the first element in each row will always be 1, so maintaining one row is enough to reach bottom-right corner of the grid | [C++](https://github.com/sankalpdayal5/LeetCode-Solutions/blob/master/C++/0062.cpp) [Java]() | O(n) | O(1) | Medium |Array Dynamic Programming | | | 0070 | [Climbing Stairs](https://leetcode.com/problems/climbing-stairs/) | steps[n]=steps[n-1]+steps[n-2]. | [C++](https://github.com/sankalpdayal5/LeetCode-Solutions/blob/master/C++/0070.cpp) [Python](https://github.com/sankalpdayal5/LeetCode-Solutions/blob/master/Python/0070.py) | O(n) | O(1) | Easy | Dynamic Programming | [📺](https://www.youtube.com/watch?v=QiD2Hbwx2z0) | | 0072 | [Edit Distance](https://leetcode.com/problems/edit-distance/) | minDis(i,j)=min(minDis(i-1,j),minDis(i,j-1),minDis(i-1,j-1))+1; | [Java](https://github.com/sankalpdayal5/LeetCode-Solutions/blob/master/Java/0072.py) | O(m*n) | O(m*n) | Hard | String Dynamic programming | | 0073 | [Set Matrix Zeroes](https://leetcode.com/problems/set-matrix-zeroes/) | Use the first cell of every row and column as a flag. This flag would determine whether a row or column has been set to zero. | [C++](https://github.com/sankalpdayal5/LeetCode-Solutions/blob/master/C++/0073.cpp) [Python](https://github.com/sankalpdayal5/LeetCode-Solutions/blob/master/Python/0073.py) | O(m*n) | O(1) | Medium | Array | [📺](https://www.youtube.com/watch?v=W1I7slnETp4) |