Untitled
unknown
plain_text
3 years ago
444 B
19
Indexable
public static int fun(String str, int x, int res) {
if (x + 2 > str.length()) {
return res;
} else if ((str.charAt(x) == 'a' && str.charAt(x + 1) == 'b' && str.charAt(x + 2) == 'c')
|| (str.charAt(x) == 'a' && str.charAt(x + 1) == 'b' && str.charAt(x + 2) == 'a')) {
res++;
return fun(str, x + 2, res);
} else {
return fun(str, x + 1, res);
}
}Editor is loading...