why my RAINBOWA solution giving Wrong answer ????

import java.util.Scanner;

/**
*

  • @author HP
    */
    class Main {

    /**

    • @param args the command line arguments
      */
      public static void main(String[] args) {
      // TODO code application logic here
      Scanner sc =new Scanner(System.in);
      int T,N;
      int[][] a;
      while(true){
      //System.out.println(“Enter the No of Test Cases:”);

      T =sc.nextInt();
       if(T>=1&&T<=100){
          a = new int[T][];
           break;
       }
      

      }
      for(int i=0;i<T;i++){
      while(true){
      // System.out.println(“Enter the no of elements in the given array”);
      N=sc.nextInt();
      if(N>=7&&N<=100){
      break;
      }
      }
      a[i]=new int[N];
      // System.out.println(“Enter the array”);
      for(int j=0;j<N;j++){
      while(true){
      // System.out.println(“Enter the no of elements in the given array”);
      a[i][j]=sc.nextInt();
      if(a[i][j]>=1&&a[i][j]<=10){
      break;
      }
      }

               //if(a[i][j]<1||a[i][j]>10)
                  // j--;
       }
      

      }
      int j,k;
      int count=1;
      int flag=0;
      for(int i=0;i<T;i++){
      j=0;
      k=a[i].length-1;

      count=1;

       while(j<=k){
           if(j!=0){
               if(a[i][j]!=a[i][j-1])
                   count++;
           }
           if((a[i][j]==a[i][k])&&(count==a[i][j])){
               
               j++;
               k--;
             
           }
           else //if ((a[i][j]==a[i][j+1]+1)||(a[i][j]==a[i][j+1]))
           {
               break;
               
           }
           
               
        ///   else{
           //    System.out.println("no");
             //  break;
           //}
       }
       if(j>k){
           System.out.println("yes");
       }
       else{
           //System.out.println("j="+j+": k="+k);
           System.out.println("no");
       }
      

      }

    }

    }

You shouldn’t be printing those arbitrary statements like “Enter the number of test cases”. It’s a machine checking your answer so just print either “yes” or “no”

Where are you checking that elements [1,7] are compulsarily there?

You are failing here-

Input
1
13
1 1 1 1 1 1 1 1 1 1 1 1 1
Your output
yes
Expected Output
no
1 Like

He has commented it.Even I was in your shoes at first :stuck_out_tongue:

Ahh wasn’t expecting that