My code link is : import java.util.*;class Test1{ public static void main(String args[] - Pastebin.com
The problems code is : RAINBOWA ( Practice-Beginners-7th question)
Here is what i get as output:
Input:
3
16
1 2 3 4 6 7 8 8 7 6 5 4 3 2 1 5
15
1 2 3 4 5 6 7 8 7 6 5 4 3 2 1
19
1 2 3 4 5 6 7 8 9 10
9 8 7 6 5 4 3 2 1
Output:
yes
yes
no
Expected output :
no
yes
yes
Where are you making sure that the numbers are in range [1,7] only? Also, please search the forums by typing the problem code in search box, most probably you will get a test case where your code fails.
But in the problem statement they have mentioned 1<=a[i]<=10 then why to check only for 7??
In the problem statement they also mentioned that RAINBOW array has elements ONLY in range [1,7]. Any other element=not rainbow.
But at least the loop in which i am checking whether the numbers are in sequence is correct right??