diff options
| author | Richard Qin <richard.qin.001@gmail.com> | 2026-09-15 08:16:43 +0800 |
|---|---|---|
| committer | Richard Qin <richard.qin.001@gmail.com> | 2026-09-15 08:16:43 +0800 |
| commit | 4022e5c95210631e4aceb08eaf9d9071aa5aefc4 (patch) | |
| tree | a5922559836e45fb3459a3d070367912e1035b1a /tests/functional/77_unique_path.sy | |
| download | rcc-master.tar.gz rcc-master.tar.xz | |
Diffstat (limited to 'tests/functional/77_unique_path.sy')
| -rw-r--r-- | tests/functional/77_unique_path.sy | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/functional/77_unique_path.sy b/tests/functional/77_unique_path.sy new file mode 100644 index 0000000..8a1074a --- /dev/null +++ b/tests/functional/77_unique_path.sy @@ -0,0 +1,35 @@ +int uniquePaths(int m, int n) { + if(m == 1 || n == 1) + return 1; + + int dp[9]; + int i; + int j; + i = 0; + while(i<m){ + dp[i*3+n-1]=1; + i = i + 1; + } + i = 0; + while(i<n){ + dp[(m-1)*3+i]=1; + i = i + 1; + } + i=m-2; + while(i > -1){ + j=n-2; + while(j > -1){ + dp[i*3+j] = dp[(i+1)*3+j] + dp[i*3+j+1]; + j = j - 1; + } + i = i - 1; + } + return dp[0]; +} +int main(){ + int res; + int n; + n=3; + res = uniquePaths(n, n); + return res; +}
\ No newline at end of file |
