gudii9
asked on
scores100 challenge
Hi,
I am working on below challenge
http://codingbat.com/prob/p179487
Pseudo Code:
1. loop through given array
2. find elemt a i position and i+1 position.
3. check their equality.
4. if equal return true
5. if not equal reurn false
I wrote my code as below
I am not passing all tests
How to improve my psedo code, approach, code? please advise
I am working on below challenge
http://codingbat.com/prob/p179487
Pseudo Code:
1. loop through given array
2. find elemt a i position and i+1 position.
3. check their equality.
4. if equal return true
5. if not equal reurn false
I wrote my code as below
public boolean scores100(int[] scores) {
boolean result=true;
int len=scores.length;
for(int i=0;i<len-1;i++){
if(scores[i]!=100&&scores[i+1]!=100){
// i=i+1;
result=false;
return result;
}
}
return result;
}
Expected Run
scores100([1, 100, 100]) → true true OK
scores100([1, 100, 99, 100]) → false true X
scores100([100, 1, 100, 100]) → true true OK
scores100([100, 1, 100, 1]) → false true X
scores100([1, 2, 3, 4, 5]) → false false OK
scores100([1, 2, 100, 4, 5]) → false false OK
other tests
OK
I am not passing all tests
How to improve my psedo code, approach, code? please advise
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Open in new window
above passes all tests.
any improvements?