public void reverseWords(char[] s) {
        if (s == null) return;

        reverse(s, 0, s.length - 1);
        int i = 0, j = 0;
        while (j < s.length) {
            while (j < s.length && s[j] != ' ') ++j;
            reverse(s, i, j - 1);
            i = j = j + 1;
        }
    }