‘READ4(char ‘BUFFER[]’)’
1) It reads 4 characters at a time from the ‘FILE’.
2) The return value of the ‘READ4’ method is the actual number of characters read.
3) For example, if in a ‘FILE’ only three characters are remaining, then it returns 3.
‘READ(char ‘BUFFER[]’, int ‘N’)’
1) ‘N’ represents the number of characters to be read from ‘FILE’.
2) In this method, you have to store your result in ‘BUFFER’.
3) In this method, you have to return the number of characters read from ‘FILE’.
‘FILE’ = “abcdef”
Initially file pointer ‘FP’ points to ‘a’.
‘READ4(BUFFER) returns 4 and ‘BUFFER’ contains “abcd”, Now the ‘FP’ points to ‘e’.
‘READ4(BUFFER) returns 2 and ‘BUFFER’ contains “ef”, Now the ‘FP’ points to the end of the ‘FILE’.
The first line of input contains an integer ‘T’ which denotes the number of test cases or queries to be run. Then the test cases follow.
The first line of each test case contains a string ‘FILE’ which represents a file that Ninja has to read.
The next line of each test case contains an integer ‘Q’, representing how many times the ‘READ’ function is called.
The next lines of each test case contain ‘Q’ space-separated integers which represent how many characters are to be read from the ‘FILE’.
For each test case, print the number of characters and actual characters which are read by Ninja from the ‘FILE’.
Print the output of each test case in a separate line.
You do not need to print anything; it has already been taken care
of. Just implement the given function.
1 <= ‘T’ <= 100
1 <= |’FILE’| <= 5000
‘FILE[i]’ = {‘a’ to ‘z’}
Where ‘T’ denotes the total number of test cases, ‘FILE’ represents the file that Ninja has to read, and |’FILE’| represents the length of the ‘FILE’.
Time Limit: 1 second
Divisible Substrings
Ninja and Numbers
Longest Palindromic Substring
Cakes
1-3 Palindrome