```
public class Solution
{
public int UniquePaths(int m, int n)
{
var preLeft = 1;
var preTops = new int[n];
for (int i = 0; i < n; i++)
{
preTops[i] = 1;
}
for (int i = 1; i < m; i++)
{
for (int j = 1; j < n; j++)
{
preTops[j] = preTops[j] + preLeft;
preLeft = preTops[j];
}
preLeft = 1;
}
return preTops[n - 1];
}
}
```