You are not logged in. Please login at www.codechef.com to post your questions!

×

Why my command prompt is showing correct answer but here its showing "wrong answer" ?

the link to the code is https://www.codechef.com/problems/RAINBOWA

this is my code, please check and help me out

import java.io.*;
import java.lang.*;
import java.util.*;

class universe
{
    public static void main(String args[])throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

        int T=Integer.parseInt(br.readLine());
        for(int j=0;j<T;j++)
        {


            int N= Integer.parseInt(br.readLine());
            int[]a= new int[N];
            String st[] = br.readLine().split(" ");
            for(int k=0;k<N;k++)
             a[k]=Integer.parseInt(st[k]);
            int tb=0;
            for(int i=0;i<=(N/2);i++)
            {
                if(tb + 1==a[i])
                tb++;
                if(tb !=a[i] || a[i] !=a[N-i-1])
                break;
            }
            if(tb==7)
            System.out.println("yes");
            else
            System.out.println("no");
        }
    }
}

asked 21 Aug '17, 11:56

rishird94's gravatar image

0★rishird94
204
accept rate: 0%

edited 21 Aug '17, 12:00


Take a look at this test case:

1
15
1 2 3 4 5 6 7 999 7 6 5 4 3 2 1
link

answered 21 Aug '17, 11:59

afaxnraner's gravatar image

6★afaxnraner
5915
accept rate: 22%

edited 21 Aug '17, 12:00

thanks, got it :)

(21 Aug '17, 12:02) rishird940★
toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×632
×226
×127
×99
×28

question asked: 21 Aug '17, 11:56

question was seen: 191 times

last updated: 21 Aug '17, 14:02