We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 418c2e2 commit 93f0461Copy full SHA for 93f0461
Course 2 - Data Structures in JAVA/Recursion Assignment/Staircase
@@ -21,3 +21,27 @@ Sample Input 2 :
21
Sample Output 2 :
22
13
23
*/
24
+
25
+public class Solution {
26
27
28
+ public static int staircase(int n){
29
30
+ /* Your class should be named Solution.
31
+ * Don't write main() function.
32
+ * Don't read input, it is passed as function argument.
33
+ * Return output and don't print it.
34
+ * Taking input and printing output is handled automatically.
35
+ */
36
+ if (n<0)
37
+ {
38
+ return 0;
39
+ }
40
+ else if (n==0)
41
42
+ return 1;
43
44
+ return staircase(n-1)+staircase(n-2)+staircase(n-3);
45
46
47
+}
0 commit comments