DSA interview question
You're building the same warehouse robot navigation simulator as before, but this time there are no obstacles — the warehouse floor is completely clear. A robot starts at the top-left corner of an m x n grid and needs to reach the bottom-right corner, moving only right or down at each step. Your task: compute the total number of distinct paths the robot can take from start to destination.
Example: a 3x7 grid → there are 28 unique ways to get from top-left to bottom-right moving only right or down.
int uniquePaths(int m, int n);
Input m | Input n | Output | Explanation |
|---|---|---|---|
| 3 | 7 | 28 | Standard grid, 6 rights + 2 downs arranged in any order |
| 3 | 2 | 3 | 3 paths: RD-D, D-RD, DD-R style arrangements |
| 1 | 1 | 1 | Start = end, exactly one trivial "path" (do nothing) |
| 1 | 5 | 1 | Single row, only one path — go straight right |
| 5 | 1 | 1 | Single column, only one path — go straight down |
| 7 | 3 | 28 | Same as (3,7) — problem is symmetric in m and n |
(Confirm: m, n >= 1; grid has no obstacles in this version.)
m and n guaranteed to be at least 1? What's the expected upper bound on m and n — does it hint at whether a DP or a closed-form combinatorial solution is expected?int, or could it be large enough to need long long / modulo arithmetic for very large grids?On Practick another engineer interviews you live for 60 minutes on a question from this bank. They have the full interviewer guide beside the call: the expected answer to every follow-up, hints to give if you stall, and a scoring rubric. You get the model solution once the session settles. It is free: interview someone for an hour and you have earned your own.
Book a free mock interviewAll 474 dsa interview questions
DSA mock interviews · System design interview questions · Free mock interview practice · Browse interviewers · Sign in