Skip to content

Instantly share code, notes, and snippets.

@Cee
Created May 31, 2014 01:56
Show Gist options
  • Save Cee/efa8b05cbbda42e47ae6 to your computer and use it in GitHub Desktop.
Save Cee/efa8b05cbbda42e47ae6 to your computer and use it in GitHub Desktop.
public class Solution {
public int uniquePaths(int m, int n) {
long ret = 1;
int a = m - 1, b = n - 1;
if ((a == 0) || (b == 0)) return 1;
if (a > b){
a = a ^ b;
b = a ^ b;
a = a ^ b;
}
for (int i = 1; i <= a; i++){
ret = ret * (a + b + 1 - i) / i;
}
return (int)(ret);
}
}
@Cee
Copy link
Author

Cee commented May 31, 2014

数学问题!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment