Accepted Java Solution


  • 3
    A

    Keep reading until either you have gotten n characters or there is no more characters to read.

    public int read(char[] buf, int n) {
        int index = 0, next = 0;
        char[] temp = new char[4];
        while (index < n && (next = read4(temp)) != 0)
            for (int i = 0; i < next && index < n; buf[index++] = temp[i++]);
        return index;
    }

  • 0
    X
    This post is deleted!

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.