public int replaceBlank(char[] string, int length) {
        // Write your code here
        int len = 0;
        for (int i = 0; i < length; ++i) {
            char c = string[i];
            if (c == ' ') {
                len += 2;
            }
            ++len;
        }
        int index = length - 1;
        for (int i = len - 1; i >= 0; --i) {
            if (string[index] == ' ') {
                string[i--] = '0';
                string[i--] = '2';
                string[i] = '%';
            } else {
                string[i] = string[index];
            }
            index -= 1;
        }
        return len;
    }