public class Solution {
public int NumberOfMatches(int teams) {
int matchesSum = 0;
while (teams > 1) {
int matches = teams / 2;
matchesSum += matches;
teams -= matches;
}
return matchesSum;
}
}
Source: https://leetcode.com/problems/count-of-matches-in-tournament/
No comments:
Post a Comment