My solution using recursion


  • 0
    S
    class Solution {
    public:
    int read(char *buf, int n) {
        int num = read4(buf);
        if(num >= n) return n;
        if(num < 4) return num;
        return 4 + 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.