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:

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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).

 

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Problems on Dynamic Programming
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education