public class Solution {
public static boolean checkAB
(String input
) {
if (input.length() == 0)
return true;
if (input.charAt(0) == 'a') {
if (input.length() >= 3 && input.substring(0, 3).equals("abb"))
return checkAB(input.substring(3));
else
return checkAB(input.substring(1));
}
return false;
}
}
cHVibGljIGNsYXNzIFNvbHV0aW9uIHsKCglwdWJsaWMgc3RhdGljIGJvb2xlYW4gY2hlY2tBQihTdHJpbmcgaW5wdXQpIHsKCQkKCQlpZiAoaW5wdXQubGVuZ3RoKCkgPT0gMCkKCQkJcmV0dXJuIHRydWU7CgoJCWlmIChpbnB1dC5jaGFyQXQoMCkgPT0gJ2EnKSB7CgoJCQlpZiAoaW5wdXQubGVuZ3RoKCkgPj0gMyAmJiBpbnB1dC5zdWJzdHJpbmcoMCwgMykuZXF1YWxzKCJhYmIiKSkKCQkJCXJldHVybiBjaGVja0FCKGlucHV0LnN1YnN0cmluZygzKSk7CgoJCQllbHNlCgkJCQlyZXR1cm4gY2hlY2tBQihpbnB1dC5zdWJzdHJpbmcoMSkpOwoJCX0KCgoJCXJldHVybiBmYWxzZTsKCX0KfQo=