Most clean and simple C++ solution


  • 0
    X
        int read(char *buf, int n) {
            int len = read4(buf);
            if (n <= 4 || n <= len) {
                return min(len, n);
            }
            return len + read(buf + 4, n - 4);        
        }
    

Log in to reply
 

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