Saved Bookmarks
| 1. |
Consider the following function: string f(int N) { if (N == 0) return "a"; if (N == 1) return "b"; if (N == 2) return "c"; return f(N - 1) + f(N - 2) + f(N - 3); } Given two integers N and K, find the Kth character in the string returned by f(N). Standard input : The first line contains two integers N and K. Standard output : If the string returned by f(N) has length less than K output −1.Otherwise, print the Kth character in the returned string.Example : Input : 2 1 Output : c |
|
Answer» (N)EXPLANATION:-+=-+=-+=-+=-+=-+=-+= |
|