C# short solution (14lines)


  • 0
    H
        char[] buffer = new char[4];
        int p0 = 0, p1 = 0;
        public int Read(char[] buf, int n) {
            int i = 0;
            for(;;) {
                while(p0 < p1 && i < n) buf[i++] = buffer[p0++];
                if (i >= n) break;
                p0 = 0;
                p1 = Read4(buffer);
                if (p1 == 0) break;
            }
            
            return i;
        }

Log in to reply
 

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