Question: Red, Green and Blue Given a pixel sequence consisting of red, green and blue pixels find the count of all contiguous subsequences such that

Red, Green and Blue Given a pixel sequence consisting of red, green and blue pixels find the count of all contiguous subsequences such that each subsequence has a minimum length of 3 and the sequence cycles between red r, green g and blue b. For eg. if the sequence starts with g then the next character in the sequence should be b and the next should be r and so on. Input Format First line of test case consists of an integer t denoting the number of test cases. Next t test cases follow. Each test case consists of two lines. First line of each test case is the length of the pixel sequence. Second line is the pixel sequence. Sample Input 5 3 rgb 4 brgb 2 rg 1 b 16 rgbrbbrgbgbrgrgb Sample Output 1 3 S&W 0 0 10
Step by Step Solution
3.49 Rating (166 Votes )
There are 3 Steps involved in it
To solve the problem we need to identify subsequences that follow the red green blue r g b pattern cyclically and have a minimum length of 3 Lets brea... View full answer
Get step-by-step solutions from verified subject matter experts
