Its first half should be non-decreasing (hence, 2nd half will be non-increasing, as its a palindrome)
It contains every element 1,2,3,4,5,6,7 and nothing more, as a(i) is a “non-zero” positive integer.
While taking inputs, you can see if you have anything which does not belong to {1, 2, …, 7}. Also, maintain an array p[7] with every value zero, and as you encounter elements, update the corresponding array element to 1. By doing a linear search for zeroes in this array p, you can see if you have all elements from 1 to 7.
Then run a for loop through the first half of the array to see if its a palindrome and non-decreasing. TADA!
Hello can anyone point out the error in the given code. I have understood the question , but cant find out the error…it seems alright to me. https://www.codechef.com/viewsolution/21937334
Thanks
the above test case 1 1 1 2 2 3 3 3 3 2 2 1 1 is not a rainbow array because rainbow array should go until it hits 7 and it should have all 1 2 3 4 5 6 7 without a skip over value.(1 2 4 5 6 7 6 5 4 2 1)(this is not a rainbow array)
(1 2 3 4 5 6 7 6 7 6 5 4 3 2 1 ) (this is also not a rainbow array either).
thanks bro for giving me some good explaination of test cases
can you plz tell me about this case 1 2 3 4 5 6 7 7 6 5 4 3 2 1 and its length is 14 is it “Yes” or “No”