I think what you want to achieve is that the array should always contain numbers in increasing order eg {1,2,4,7,12} and thing like
{1,3,4,5,2} or {2,5,8,3} should return false.
So if i dry run my code for these inputs i think it gives correct results , can you give me a case where it doesn't works ?
no it does not work in all conditions.
rule is that we have to make sure {1,2,3} returns true but not {1,3,2}
public boolean scoresIncreasing(int[] scores) {
int a= scores.length;
boolean b = true;
for (int i=0; i<a;i++) { int c =scores[i];
int d= scores[i+1];
if (a>=2 && c>d)
{ b= false;
// If at any point in the array previous value is > then
// no need to check further just break for loop & return false
break;
}
}
return b;
}
[ March 11, 2008: Message edited by: Jyoti S ]