|
1 | 1 | packagecom.fishercoder.solutions;
|
2 | 2 |
|
3 |
| -/** |
4 |
| - * 158. Read N Characters Given Read4 II - Call multiple times |
5 |
| - * |
6 |
| - * The API: int read4(char *buf) reads 4 characters at a time from a file. |
7 |
| - * The return value is the actual number of characters read. For example, it returns 3 if there is only 3 characters left in the file. |
8 |
| - * By using the read4 API, implement the function int read(char *buf, int n) that reads n characters from the file. |
9 |
| - * |
10 |
| - * Note: |
11 |
| - * The read function may be called multiple times. |
12 |
| - * |
13 |
| - * Example 1: |
14 |
| - * Given buf = "abc" |
15 |
| - * read("abc", 1) // returns "a" |
16 |
| - * read("abc", 2); // returns "bc" |
17 |
| - * read("abc", 1); // returns "" |
18 |
| - * |
19 |
| - * Example 2: |
20 |
| - * Given buf = "abc" |
21 |
| - * read("abc", 4) // returns "abc" |
22 |
| - * read("abc", 1); // returns "" |
23 |
| - */ |
24 | 3 | publicclass_158 {
|
25 | 4 |
|
26 | 5 | publicstaticclassSolution1 {
|
|