Solve counting unique paths problem in leetcode, O(n * m) time and space.