😎풀이

  1. grid 순회
    1-1. 현재 팀의 승리 횟수 확인
    1-2. 챔피온 팀의 승리 횟수와 대소 비교
    1-3. 챔피온 팀보다 많은 승리를 했을 경우, 정보 갱신
  2. 챔피온 팀 반환
function findChampion(grid: number[][]): number {
    let champion: number
    let maxWin = 0
    for(let team = 0; team < grid.length; team++) {
        const matches = grid[team]
        const win = matches.filter(match => match).length
        if(win < maxWin) continue
        maxWin = win
        champion = team
    }
    return champion
};
profile
내 지식을 공유할 수 있는 대담함

0개의 댓글