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/
"Simplicity can't be bought later, it must be earned from the start" -- DB
Thursday, February 18, 2021
Leetcode Everyday: 1688. Count of Matches in Tournament. Easy
Labels:
leetcode
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment