A frog can jump either one foot or two feet at once, given the distance between its resting place and the pond in feet, Write a program to get the number of ways in which the frog can reach the pond from its resting place.
Input (int) | Output(List) |
---|---|
1 | [1] |
0 | [] |
3 | [111, 12, 21] |
-6 | [] |
6 | [111111, 11112, 11121, 11211, 12111, 21111, 1122, 1212, 1221, 2112, 2121, 2211, 222] |
class FindPossibleFrogJumps
{ public static void main(String s[])
{
List result = getPossibleJumps(6);
System.out.println("The possible jumps are: " + result);
}
public static List<String> getPossibleJumps(int number) {
//Write code here to find possible frog jumps
}
//Use this for writing additional methods if required
}
Topic: Collection Framework In Java