top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Find All possible paths down stairs.

+5 votes
243 views

Given a staircase with N steps, you can go up with 1 or 2 or 3 steps each time. Output all possible way you go from bottom to top.

For example:

N = 3

Output :
1 1 1
1 2
2 1
3

N = 4

Output:
1 1 1 1
1 2 1
1 1 2
2 1 1
3 1
1 3
2 2

posted Nov 18, 2013 by Mona Sharma

Looking for an answer?  Promote on:
Facebook Share Button Twitter Share Button LinkedIn Share Button

Similar Questions
+3 votes

Say the given string is ABC

Output should be ABC ACB BAC BCA CBA CAB

+6 votes

For example: It returns ‘b’ when the input is “abaccdeff”.

+5 votes

Given an unsorted array, find the max length of subsequence in which the numbers are in incremental order.

For example: If the input array is {7, 2, 3, 1, 5, 8, 9, 6}, a subsequence with the most numbers in incremental order is {2, 3, 5, 8, 9} and the expected output is 5.

+5 votes
      40
      /\
     20 60
     /\  \
   10 30  80
      /   /\
     25  70 90
           \
           75

longest path 
25 30 20 40 60 80 70 75 
Answer
    25 ----> 75
...