Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
444 B
2
Indexable
Never
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);
        }
    }