Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a4a486d

Browse files
committedApr 26, 2025
Add solution #1688
1 parent 859f17b commit a4a486d

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed
 

‎README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 1,475 LeetCode solutions in JavaScript
1+
# 1,476 LeetCode solutions in JavaScript
22

33
[https://leetcodejavascript.com](https://leetcodejavascript.com)
44

@@ -1300,6 +1300,7 @@
13001300
1685|[Sum of Absolute Differences in a Sorted Array](./solutions/1685-sum-of-absolute-differences-in-a-sorted-array.js)|Medium|
13011301
1686|[Stone Game VI](./solutions/1686-stone-game-vi.js)|Medium|
13021302
1687|[Delivering Boxes from Storage to Ports](./solutions/1687-delivering-boxes-from-storage-to-ports.js)|Hard|
1303+
1688|[Count of Matches in Tournament](./solutions/1688-count-of-matches-in-tournament.js)|Easy|
13031304
1716|[Calculate Money in Leetcode Bank](./solutions/1716-calculate-money-in-leetcode-bank.js)|Easy|
13041305
1718|[Construct the Lexicographically Largest Valid Sequence](./solutions/1718-construct-the-lexicographically-largest-valid-sequence.js)|Medium|
13051306
1726|[Tuple with Same Product](./solutions/1726-tuple-with-same-product.js)|Medium|
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* 1688. Count of Matches in Tournament
3+
* https://leetcode.com/problems/count-of-matches-in-tournament/
4+
* Difficulty: Easy
5+
*
6+
* You are given an integer n, the number of teams in a tournament that has strange rules:
7+
* - If the current number of teams is even, each team gets paired with another team. A total
8+
* of n / 2 matches are played, and n / 2 teams advance to the next round.
9+
* - If the current number of teams is odd, one team randomly advances in the tournament, and
10+
* the rest gets paired. A total of (n - 1) / 2 matches are played, and (n - 1) / 2 + 1 teams
11+
* advance to the next round.
12+
*
13+
* Return the number of matches played in the tournament until a winner is decided.
14+
*/
15+
16+
/**
17+
* @param {number} n
18+
* @return {number}
19+
*/
20+
var numberOfMatches = function(n) {
21+
return n - 1;
22+
};

0 commit comments

Comments
 (0)
Please sign in to comment.