Accepted Simple Java Solution


  • 0
    M
    public int read(char[] buf, int n) {
            if(n <= 0) {
                return n;
            }
            char[] temp = new char[4];        
            int i = 0;
            while(i < n) {
                int read = read4(temp);
                int j = 0;
                while(j < read && i < n) {
                    buf[i++] = temp[j++];
                }
                
                if(read < 4) {
                    break;
                }
            }  
            return i;
        }
    

Log in to reply
 

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