approached to pick some integer k (k>0) and find a succession an of length k with the end goal that: 1≤a1
Correct answer will be upvoted else downvoted. Computer science.
You are approached to pick some integer k (k>0) and find a succession an of length k with the end goal that:
1≤a1<a2<⋯<ak≤|s|;
The characters at positions a1,a2,… ,ak are taken out, the excess characters are linked without changing the request. Thus, at the end of the day, the situations in the arrangement an ought not be contiguous.
Allow the subsequent to string be s′. s′ is called arranged if for all I from 2 to |s′| s′i−1≤s′i.
Does there exist such a grouping a that the subsequent string s′ is arranged?
Input
The main line contains a solitary integer t (1≤t≤1000) — the number of testcases.
Then, at that point, the portrayals of t testcases follow.
The main line of each testcase contains a string s (2≤|s|≤100). Each character is either '0' or '1'.
Output
For each testcase print "YES" if there exists a grouping a to such an extent that eliminating the characters at positions a1,a2,… ,ak and linking the parts without changing the request delivers an arranged string.
In any case, print "NO".
Step by step
Solved in 4 steps with 1 images