Short 7 lines C++ solution.


  • 0
    N
     int read(char *buf, int n) {
            int curr = 0, ans = 0;
            while ((n-=curr) > 0 && (curr=min(read4(buf),n))) {
                buf += curr;
                ans += curr;
            }
            return ans;
        }
    

Log in to reply
 

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