Codey and Connection
https://www.hackerrank.com/contests/codenection-2023-final-round-closed-category/challenges/cn-c11/problem
Question
Codey is a huge fan of CodeNection, and one day, while enjoying a CodeNection-themed article he noticed that the word 'Connection' closely resembles 'CodeNection'. Excited by this idea, Codey prepared a sequence of n uppercase alphabetical letters, all lined up from left to right. Codey decided to connect these letters following a specific rule:
Let the index of the previously connected letter be , and pick an integer where . If no letter was connected previously, Codey could pick any .
Connect to .
Codey is now curious to know if it's possible to connect these letters in a way that spells out the word CODENECTION from left to right. Can you help Codey figure it out?
Input Format
The first line contains an integer t, which represents the amount of test cases for the problem.
The following provides the description of each test case:
The first line contains an integer
n, which represents the number of letters in the sequence of uppercase letters.The second line contains the sequence of
nuppercase letters.
Constraints
Output Format
Output YES for each test case if its possible to spell out CODENECTION otherwise output NO.
Sample Inputs:
Last updated
