import java.util.*;
class Program {
public String tournamentWinner(
String finalWinner = "";
int finalWinNum = 0;
for(int i = 0; i < results.size(); i++){
int winIndex = results.get(i);
ArrayList<String> comp = competitions.get(i);
String winner = comp.get(winIndex == 0 ? 1 : 0);
int oldScore = teamData.containsKey(winner) ? teamData.get(winner) : 0;
int newScore = oldScore + 3;
if (newScore > finalWinNum){
finalWinner = winner;
finalWinNum = newScore;
}
teamData.put(winner, newScore);
}
return finalWinner;
}
}
'Algorithms and Data Structures > Coding Practices' 카테고리의 다른 글
AlgoExpert Sorted Squared Array (0) | 2022.07.10 |
---|---|
AlgoExpert Non-Constructible Change (0) | 2022.07.10 |
LeetCode 45. Jump Game II (0) | 2022.07.08 |
LeetCode 189. Rotate Array (0) | 2022.06.18 |
LeetCode 67. Add Binary (0) | 2022.06.14 |