You are viewing a single comment's thread. Return to all comments →
Hi ,
Im trying the brute force approach.
It is working for some of the test cases .But it is failing for some.
This is failing for testcase 1.Im not sure.I have debugged it my local.
Can someone from hackerrank take a look at it.
Can someone find it.
for(int i=0; i< arr.length;i++) { for(int j=i;j<arr.length;j++){ boolean isSorted = true; for(int k=i;k<=j;k++){ if((k+1 <= j) && (arr[k] > arr[k+1]) ){ isSorted = false; break; } } if(!isSorted){ break; }else { count++; } } }
Seems like cookies are disabled on this browser, please enable them to open this website
Almost sorted interval
You are viewing a single comment's thread. Return to all comments →
Hi ,
Im trying the brute force approach.
It is working for some of the test cases .But it is failing for some.
This is failing for testcase 1.Im not sure.I have debugged it my local.
Can someone from hackerrank take a look at it.
Can someone find it.