#C9803. Unique Paths in a Grid
Unique Paths in a Grid
Unique Paths in a Grid
Given an (M \times N) matrix, find all unique paths from the top-left corner to the bottom-right corner by only moving rightwards and downwards. A valid path is represented by a string consisting of the characters 'D' (down) and 'R' (right).
For example, in a 2×2 matrix, there are exactly two unique paths: DR
and RD
.
inputFormat
The first line of input contains two integers (M) and (N) separated by a space, representing the number of rows and columns of the matrix.
outputFormat
Output all unique paths from the top-left to the bottom-right of the matrix, separated by a space, in the order they are discovered.## sample
2 2
DR RD