|
|
|
|
|
|
i****5 发帖数: 6 | 1 /*
Stairs = {0..n}
At each stair step size of 1 or 2.
input: n
output: All possible sequences from 0 to n.
e.g. For input n = 3
output
0 1 2 3 <- 1 1 1
0 1 3 <- 1 2
0 2 3 <- 2 1
*/
I tried to use stack and recursion to solve this problem. Is there any
other solution? | p*****2 发帖数: 21240 | 2
DP也可以。
【在 i****5 的大作中提到】 : /* : Stairs = {0..n} : At each stair step size of 1 or 2. : input: n : output: All possible sequences from 0 to n. : e.g. For input n = 3 : output : 0 1 2 3 <- 1 1 1 : 0 1 3 <- 1 2 : 0 2 3 <- 2 1
| s***y 发帖数: 3042 | 3 DP
【在 i****5 的大作中提到】 : /* : Stairs = {0..n} : At each stair step size of 1 or 2. : input: n : output: All possible sequences from 0 to n. : e.g. For input n = 3 : output : 0 1 2 3 <- 1 1 1 : 0 1 3 <- 1 2 : 0 2 3 <- 2 1
| W***n 发帖数: 11530 | 4
This is a stupid question as well. Avoid this company.
【在 i****5 的大作中提到】 : /* : Stairs = {0..n} : At each stair step size of 1 or 2. : input: n : output: All possible sequences from 0 to n. : e.g. For input n = 3 : output : 0 1 2 3 <- 1 1 1 : 0 1 3 <- 1 2 : 0 2 3 <- 2 1
|
|
|
|
|
|