We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 176ee36 commit 418c2e2Copy full SHA for 418c2e2
Course 2 - Data Structures in JAVA/Recursion Assignment/Check AB
@@ -25,3 +25,29 @@ abababa
25
Sample Output 2 :
26
false
27
*/
28
+public class Solution {
29
+
30
+ public static boolean checkAB(String input) {
31
+ // Write your code here
32
+ if (input.length()==0)
33
+ {
34
+ return true;
35
+ }
36
37
+ if (input.charAt(0) != 'a')
38
39
+ return false;
40
41
42
+ if (input.length() >= 3 && input.substring(0,3).equals("abb"))
43
44
+ return checkAB(input.substring(3));
45
46
+ else
47
48
+ return checkAB(input.substring(1));
49
50
51
52
53
+}
0 commit comments