Code RoomLattice paths count
MediumPrep Room Coding #758

Lattice paths count

CodingAlgorithms & data structuresMid–Senior~20 min

On a grid with (rows+1) by (cols+1) intersection points, you start at the top-left corner and may step only right or down by one unit at a time until you reach the bottom-right corner. Return the number of distinct monotonic lattice paths, modulo mod. For example, a 2-by-2 grid of moves (2 rights, 2 downs) has 6 paths. Assume 0 <= rows, cols <= 30 and mod >= 2.

Implement
lattice_paths_mod(rows: int, cols: int, mod: int) → int
Examples
in[2,2,1000000007]out6
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 20 min
InputExpectedGot
[2,2,1000000007]6not run yetsample