Method to convert String to int array
Ohhhh.... XOR logic on booleans in Java ..... how esoteric:


if (s.charAt(i) == ' ' ^ i == s.length() - 1) {



That should be removed "just because". It's hard to understand, the logic is inverted, and it is not short-circuit, so it tests the i == s.length() - 1 even when s.charAt(i) == ' '

I think what you have is an inverted logic problem. You are looking for all the digits in the input, when, instead, you should be looking for not-digits....

The supporting logic, using StringBuilders, etc. is not a bad idea.... but, have you considered a regular-expression?

String[] digitwords = input.split("\\D+");
int[] result = new int[digitwords.length];
for (int i = 0; i &lt; result.length; i++) {
    result[i] = Integer.parseInt(digitwords[i]);
}
return result;


The split there, is "split on all sequences that do not contain digits"

Java8 may help (with an added filter to remove empty values, not in the loop above), with:

return Arrays.stream(input.split("\\D+"))
       .filter(word -&gt; !word.isEmpty())
       .mapToInt(Integer::parseInt)
       .toArray();