Google | Phone | Climbing Stairs
Anonymous User
822

As the title says, give all combinations in order to reach step 'N' with only allowed leap sizes of 1 and 2

Ex 1: N = 1
['1']

Ex 2: N = 2
['11', '2']

Ex 3: N = 3
['111', '21', '12']

Ex 3: N = 4
['1111', '112, '121', '211', '22']

Answer: Add '1' to all possible solutions to N-1'th level, add '2' to all possible solutions to N-2'th level and combine both to get all possible solutions to N'th level

Comments (5)