Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added 0062 cpp code and updated readme #66

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions C++/0062.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class Solution {
public:
int uniquePaths(int m, int n) {
vector<vector<int>> dp(m, vector<int>(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];
}
};
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) |
Expand Down