Trains the technique from
LeetCode 62Unique PathsThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A bicycle courier works a planned district shaped as m streets running east-west crossed by n streets running north-south, giving m rows and n columns of intersections.
The courier waits at the intersection in the northwest corner, row 1 and column 1, and must deliver to the intersection in the southeast corner, row m and column n. Traffic rules allow exactly two kinds of step: ride one block east, landing on the next column of the same row, or ride one block south, landing on the next row of the same column.
Two routes count as different when the sequence of steps differs. Return how many different routes reach the delivery point.
Example 1
Any route takes 3 southbound blocks and 4 eastbound blocks in some order, and there are 35 such orders.
Example 2
A single row leaves no room to ride south, so the only route is five straight eastbound blocks.
Example 3
The courier either rides east then south, or south then east.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def count_routes(m: int, n: int) -> int:public int countRoutes(int m, int n)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.