From 56748ff1f1e160349efe6ed52fa497bddf62f559 Mon Sep 17 00:00:00 2001 From: japnit01 <63052755+japnit01@users.noreply.github.com> Date: Sun, 18 Oct 2020 12:40:13 +0530 Subject: [PATCH] Create Unique_paths.cpp The no. of unique paths starting from top left corner to bottom right corner --- C++/Unique_paths.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 C++/Unique_paths.cpp diff --git a/C++/Unique_paths.cpp b/C++/Unique_paths.cpp new file mode 100644 index 0000000..50a0d2f --- /dev/null +++ b/C++/Unique_paths.cpp @@ -0,0 +1,28 @@ +#include + using namespace std; + + int uniquePaths(int m, int n) { + int A[m][n],i,j; + for(i=m-1;i>=0;i--) + { + for(j=n-1;j>=0;j--) + { + if(i==m-1||j==n-1) + { + A[i][j]=1; + } + else + { + A[i][j]=A[i][j+1]+A[i+1][j]; + } + } + } + return A[0][0]; + } + +int main() +{ + int m,n; + cin>>m>>n; + cout<