You are given a string S consisting of lowercase alphabets and an integer array val consisting of N integers. Using the given string S and array val, you need to create another string X according to the code snippet below:
Initially string X is empty
Let len be the length of string S
for i := 0 to N-1
pos := absolute value of val[i]
if(val[i] >= 0)
X := X + S[0,pos] // append substring of string S from index 0 to pos (both including) into X
else
X := X + S[pos,len-1] // append substring of string S from index pos to len-1 (both including) into X
You have to answer Q tasks. For each task, you are given an integer K and you have to print the Kth vowel in the string X. If the Kth vowel doesn't exist print -1.
Note: The vowels are a, e, i, o, and u.
Input Format:
The first line contains a string S.
The second line contains an integer N.
The third line contains N space-separated integers, denoting the element of the array val.
The fourth line contains an integer Q, denoting the number of tasks.
The fifth line contains Q space-separated integers, denoting the tasks.
Output Format:
Print the answer for each of the Q tasks in a newline.
Constraints:
\(1 \le |S|,N,Q \le10^5\)
\(0\le |val_i| \le|S|-1\)
\(1 \le K \le 10^{10}\)
All the characters of string S are lowercase characters only.
The String Obtained X="ouiouae"
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor