#K47667. Rainbow Sequence Checker
Rainbow Sequence Checker
Rainbow Sequence Checker
You are given several test cases. In each test case, you have a sequence of balloon colors provided as space‐separated strings. A rainbow sequence is defined as the consecutive appearance of the following seven colors in this exact order:
\( red,\ orange,\ yellow,\ green,\ blue,\ indigo,\ violet \)
Your task is to determine if a rainbow sequence exists in the given sequence. If found, output Yes
; otherwise, output No
for that test case.
Note: The sequence may contain extra colors before or after a valid rainbow sequence.
inputFormat
The first line of input contains an integer T representing the number of test cases. Each of the following T lines contains a test case with a sequence of space-separated balloon colors.
outputFormat
For each test case, output a single line containing Yes
if there exists a consecutive subsequence matching \( red,\ orange,\ yellow,\ green,\ blue,\ indigo,\ violet \); otherwise, output No
.
3
red orange yellow green blue indigo violet
red orange green yellow green blue indigo violet
red orange yellow blue green indigo violet
Yes
No
No
</p>