public boolean scoresIncreasing(int[] scores) {
boolean result=false;
int len=scores.length;
for(int i=0;i<len;i++){
if(scores[i+1]>scores[i]&&scores[i+2]>scores[i+1]){
result=true;
return result;
}
}
return result;
}
Expected Run
scoresIncreasing([1, 3, 4]) → true true OK
scoresIncreasing([1, 3, 2]) → false Exception:java.lang.ArrayIndexOutOfB oundsExcep tion: 3 (line number:5) X
scoresIncreasing([1, 1, 4]) → true Exception:java.lang.ArrayIndexOutOfB oundsExcep tion: 3 (line number:5) X
scoresIncreasing([1, 1, 2, 4, 4, 7]) → true true OK
scoresIncreasing([1, 1, 2, 4, 3, 7]) → false true X
scoresIncreasing([-5, 4, 11]) → true true OK
Your progress graph for this problem
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Most Valuable Expert award recognizes technology experts who passionately share their knowledge with the community, demonstrate the core values of this platform, and go the extra mile in all aspects of their contributions. This award is based off of nominations by EE users and experts. Multiple MVEs may be awarded each year.