troubleshooting Question

scoresIncreasing challenge

Avatar of gudii9
gudii9Flag for United States of America asked on
JavaJava EEProgramming
10 Comments2 Solutions191 ViewsLast Modified:

I am working on below challege.
my psedo code :
1. loop thorugh given array.
2. compare first array element with second and alsos third with second to make sure later is bigger than earlier one.
3. if yes return true.
4. if no return false

public boolean scoresIncreasing(int[] scores) {
  boolean result=false;
  int len=scores.length;
for(int i=0;i<len;i++){
    return result;
return result;

Expected      Run            
scoresIncreasing([1, 3, 4]) → true      true      OK      
scoresIncreasing([1, 3, 2]) → false      Exception:java.lang.ArrayIndexOutOfBoundsException: 3 (line number:5)      X      
scoresIncreasing([1, 1, 4]) → true      Exception:java.lang.ArrayIndexOutOfBoundsException: 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

i am failing few tests. How to fix and improve my code. please advise
Join our community to see this answer!
Unlock 2 Answers and 10 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 10 Comments.
Try for 7 days

”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.

-Mike Kapnisakis, Warner Bros