2021-07-15 게시 됨2026-04-09 업데이트 됨Algorithm / LeetCode0회 방문[LeetCode] 1688. Count of Matches in Tournament문제 보기Kotlin 123456789101112131415161718class Solution { fun numberOfMatches(n: Int): Int { var remains = n var cnt = 0 while (remains > 1) { if (remains % 2 == 0) { cnt += remains / 2 remains /= 2 } else { cnt += (remains - 1) / 2 remains = (remains - 1) / 2 + 1 } } return cnt }} #KotlinAlgorithmLeetCodeSimulation [LeetCode] 1688. Count of Matches in Tournamenthttps://june0122.github.io/2021/07/15/leetcode-1688/AuthorKAMIYUPosted on2021-07-15Updated on2026-04-09Licensed under#KotlinAlgorithmLeetCodeSimulation