Skip to content

Commit 7a1ceeb

Browse files
committed
feat(leetcode): add No.1688
1 parent 1861af6 commit 7a1ceeb

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// https://leetcode.com/problems/count-of-matches-in-tournament/
2+
// algorithms
3+
// Easy (83.94%)
4+
// Total Accepted: 5,565
5+
// Total Submissions: 6,630
6+
7+
8+
class Solution {
9+
public int numberOfMatches(int n) {
10+
int res = 0;
11+
12+
while (n > 1) {
13+
int tmp = n / 2;
14+
15+
16+
res += tmp;
17+
n -= tmp;
18+
}
19+
20+
return res;
21+
}
22+
}

0 commit comments

Comments
 (0)