1 2 3 4 5 6 7 8 9 10 11 12 | public class Solution { public int NumberOfMatches( int teams) { int matchesSum = 0; while (teams > 1) { int matches = teams / 2; matchesSum += matches; teams -= matches; } return matchesSum; } } |
"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