Polycarp chooses two numbers I and j (1≤i≤j≤n) and eliminates characters from the s string at the positions i,i+1,i+2,… ,j (for example eliminates substring s[i… j]). All the more officially, Polycarp transforms the string s into the string s1s2… si−1sj+1sj+2… sn. For instance, the string s="20192020" Polycarp can transform into strings:
Correct answer will be upvoted else Multiple Downvoted. Computer science.
Polycarp chooses two numbers I and j (1≤i≤j≤n) and eliminates characters from the s string at the positions i,i+1,i+2,… ,j (for example eliminates substring s[i… j]). All the more officially, Polycarp transforms the string s into the string s1s2… si−1sj+1sj+2… sn.
For instance, the string s="20192020" Polycarp can transform into strings:
"2020" (for this situation (i,j)=(3,6) or (i,j)=(1,4));
"2019220" (for this situation (i,j)=(6,6));
"020" (for this situation (i,j)=(1,5));
different tasks are likewise conceivable, a couple of them are recorded previously.
Polycarp loves the string "2020" definitely, so he is contemplating whether it is feasible to transform the string s into a string "2020" in close to one activity? Note that you can perform zero activities.
Input
The principal line contains a positive integer t (1≤t≤1000) — number of experiments in the test. Then, at that point, t experiments follow.
The primary line of each experiment contains an integer n (4≤n≤200) — length of the string s. The following line contains a string s of length n comprising of decimal digits. It is permitted that the string s begins with digit 0.
Output
For each experiment, output on a different line:
"Indeed" if Polycarp can transform the string s into a string "2020" in close to one activity (for example he can perform 0 or 1 activity);
"NO" in any case.
You might print each letter of "YES" and "NO" regardless you need (in this way, for instance, the strings yEs, indeed, Yes and YES will be generally perceived as certain reply).
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 1 images