
Given:- 'S' = “codingninjas”, ‘K’ = 5
The output will be 'n'.
Since the character at the kth index is S[4] = ‘n’.
The first line of input contains an integer ‘T’ denoting the number of test cases.
The following ‘T’ lines contain a string ‘S’ and an integer ‘K.’
For each test case, print a single line containing a single character denoting the ‘K-th’ letter (0 indexed) in the decoded string.
The output of each test case will be printed 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 <= 5
1 <= |S| <= 100
1 <= K <= |S| * |S|
Where ‘T’ is the total number of test cases, and ‘|S|’ is the length of the string and ‘K’ is the number given.
Time limit: 1 sec.
The main idea is when a decoded string is equal to some word with some length repeated some number of times, the answer is the same for the index ‘K’ as it is for the index K % length.