Hey! I’m trying to make this algorithm take much less space when it comes to running it and I can’t seem to simplify it down. Any tips?
int[] scores = {first, second};
int max = first;
for (int i = 0; i < scores.length; i++) {
if (max < scores[i]) {
max = scores[i];
}
if (scores[0] == scores[1]) {
if (firstStarted == true) {
winner = 2;
} else if (firstStarted == false) {
winner = 1;
}
} else if (max == first) {
winner = 1;
} else if (max == second) {
winner = 2;
}
}
System.out.println(winner);