Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

Taking error need assistance

$
0
0

question :- http://www.hackerearth.com/eksmscom-hiring-challenge/algorithm/inverse-list/ answer :-

public static void main(String args[] ) throws Exception 
{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int ctr=0;
    int t=Integer.parseInt(br.readLine());
    for(int i=0;i<t;i++)
    {
        int n=Integer.parseInt(br.readLine());
        String input[]=(br.readLine()).split(" ");
        for(int j=0;j<n;)
        {
            if(Integer.parseInt(input[j]) == ++j)
            {
                ctr++;
            }
        }
        if(ctr==n)
        {

            System.out.println("inverse"); 
        }
        else
        {

            System.out.println("not inverse");
        }
        ctr=0;
    }
}

}


Though too trivial, the solution is shown correct when i compile and run, but on submitting, it gives WA.


Viewing all articles
Browse latest Browse all 39796


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>