Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.
Become a Premium Member and unlock a new, free course in leading technologies each month.
public int scoresAverage(int[] scores) {
int result=0;
int len=scores.length;
int lenHalf=len/2;
int sumEven=0;
int sumOdd=0;
for(int i=0;i<lenHalf;i++){
sumEven=(scores[i]+scores[i+1])/2;
//result=sumeEven;
//return result;
}
for(int i=lenHalf;i<len;i++){
sumOdd=(scores[i]+scores[i+1])/2;
// result=sumeOdd;
//return result;
}
if(sumOdd>sumEven){
return sumOdd;
}
else{
return sumEven;
}
}
return result;
}
}
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
public int scoresAverage(int[] scores) {
int result=0;
int len=scores.length;
int lenHalf=len/2;
int sumEven=0;
int sumOdd=0;
for(int i=0;i<lenHalf;i++){
sumEven=(scores[i]+scores[i+1])/2;
//result=sumeEven;
//return result;
}
for(int i=lenHalf;i<len;i++){
sumOdd=(scores[i]+scores[i+1])/2;
// result=sumeOdd;
//return result;
}
if(sumOdd>sumEven){
return sumOdd;
}
else{
return sumEven;
}
return result;
}
public int scoresAverage(int[] scores) {
int result=0;
int len=scores.length;
int lenHalf=len/2;
int sumEven=0;
int sumOdd=0;
if(len>2){
for(int i=0;i<lenHalf-1;i++){
sumEven=(scores[i]+scores[i+1])/2;
//result=sumeEven;
//return result;
}
for(int i=lenHalf;i<len-1;i++){
sumOdd=(scores[i]+scores[i+1])/2;
// result=sumeOdd;
//return result;
}
if(sumOdd>sumEven){
result=sumOdd;
return result;
}
else{
result=sumEven;
return result;
}
}
else{
if(scores[0]>scores[1]){
result=scores[0];
return result;
}
else{
result=scores[1];
return result;
}
}
}
If you are experiencing a similar issue, please ask a related question
Join the community of 500,000 technology professionals and ask your questions.