Brian Yang
Brian Yang
algorithm designer
Mar 30, 2020 1 min read

Lattice Paths

Count the number of unique paths to travel from the top left corner to the bottom right corner of a lattice of M x N squares.

Solution

const robotPaths = (h, v) => {
  if (h < 1 && v < 1) return 1
  if (h === 0 && v === 0) return 0
  return robotPaths(h - 1, v) + robotPaths (h, v - 1)
}
comments powered by Disqus