Simple C++ soulution


  • 0
    Z
    
    class Solution {
    public:
        /**
         * @param buf Destination buffer
         * @param n   Maximum number of characters to read
         * @return    The number of characters read
         */
        int read(char *buf, int n) {
            int res=0;
            int tmp=0;
            while((tmp=read4(buf))!=0){
                res+=tmp;
                buf+=tmp;
            }
            return res<n?res:n;
        }
    };
    

Log in to reply
 

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