Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 78fe74b

Browse files
committed
feat: add solutions to lc problem: No.1688
No.1688.Count of Matches in Tournament
1 parent 0744ae8 commit 78fe74b

File tree

7 files changed

+102
-4
lines changed

7 files changed

+102
-4
lines changed

‎solution/1600-1699/1688.Count of Matches in Tournament/README.md‎

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,27 +48,65 @@
4848
<li><code>1 &lt;= n &lt;= 200</code></li>
4949
</ul>
5050

51-
5251
## 解法
5352

5453
<!-- 这里可写通用的实现逻辑 -->
5554

55+
n 个人比赛,最终淘汰 n - 1 个人,所以配对次数是 n - 1。
56+
5657
<!-- tabs:start -->
5758

5859
### **Python3**
5960

6061
<!-- 这里可写当前语言的特殊实现逻辑 -->
6162

6263
```python
63-
64+
class Solution:
65+
def numberOfMatches(self, n: int) -> int:
66+
return n - 1
6467
```
6568

6669
### **Java**
6770

6871
<!-- 这里可写当前语言的特殊实现逻辑 -->
6972

7073
```java
74+
class Solution {
75+
public int numberOfMatches(int n) {
76+
return n - 1;
77+
}
78+
}
79+
```
80+
81+
### **C++**
82+
83+
```cpp
84+
class Solution {
85+
public:
86+
int numberOfMatches(int n) {
87+
return n - 1;
88+
}
89+
};
90+
```
91+
92+
### **Go**
93+
94+
```go
95+
func numberOfMatches(n int) int {
96+
return n - 1
97+
}
98+
```
99+
100+
### **JavaScript**
71101

102+
```js
103+
/**
104+
* @param {number} n
105+
* @return {number}
106+
*/
107+
var numberOfMatches = function (n) {
108+
return n - 1;
109+
};
72110
```
73111

74112
### **...**

‎solution/1600-1699/1688.Count of Matches in Tournament/README_EN.md‎

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,57 @@ Total number of matches = 7 +たす 3 +たす 2 +たす 1 = 13.
4646
<li><code>1 &lt;= n &lt;= 200</code></li>
4747
</ul>
4848

49-
5049
## Solutions
5150

5251
<!-- tabs:start -->
5352

5453
### **Python3**
5554

5655
```python
57-
56+
class Solution:
57+
def numberOfMatches(self, n: int) -> int:
58+
return n - 1
5859
```
5960

6061
### **Java**
6162

6263
```java
64+
class Solution {
65+
public int numberOfMatches(int n) {
66+
return n - 1;
67+
}
68+
}
69+
```
70+
71+
### **C++**
72+
73+
```cpp
74+
class Solution {
75+
public:
76+
int numberOfMatches(int n) {
77+
return n - 1;
78+
}
79+
};
80+
```
81+
82+
### **Go**
83+
84+
```go
85+
func numberOfMatches(n int) int {
86+
return n - 1
87+
}
88+
```
89+
90+
### **JavaScript**
6391

92+
```js
93+
/**
94+
* @param {number} n
95+
* @return {number}
96+
*/
97+
var numberOfMatches = function(n) {
98+
return n - 1;
99+
};
64100
```
65101

66102
### **...**
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class Solution {
2+
public:
3+
int numberOfMatches(int n) {
4+
return n - 1;
5+
}
6+
};
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
func numberOfMatches(n int) int {
2+
return n - 1
3+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class Solution {
2+
public int numberOfMatches(int n) {
3+
return n - 1;
4+
}
5+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* @param {number} n
3+
* @return {number}
4+
*/
5+
var numberOfMatches = function(n) {
6+
return n - 1;
7+
};
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class Solution:
2+
def numberOfMatches(self, n: int) -> int:
3+
return n - 1

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /