My 7 line accepted java solution


  • 0
    A
        public int read(char[] buf, int n) {
            int bytesRead, read = 0;
            char[] curBuf = new char[4];
            do {
                bytesRead = Math.min(read4(curBuf), n - read);
                for (int j=1;j<=bytesRead;j++) buf[(++read)-1] = curBuf[j-1];
            } while ( (read<n) && (bytesRead==4) );
            return read;
        }
    

Log in to reply
 

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