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 3bdc38c

Browse files
authored
feat: add php solution to lc problem: No.1984 (#1074)
1 parent 00ae005 commit 3bdc38c

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

‎solution/1900-1999/1984.Minimum Difference Between Highest and Lowest of K Scores/README.md‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,26 @@ impl Solution {
146146
}
147147
```
148148

149+
### **PHP**
150+
151+
```php
152+
class Solution {
153+
/**
154+
* @param Integer[] $nums
155+
* @param Integer $k
156+
* @return Integer
157+
*/
158+
function minimumDifference($nums, $k) {
159+
sort($nums);
160+
$rs = 10 ** 5;
161+
for ($i = 0; $i < count($nums) - $k + 1; $i++) {
162+
$rs = min($rs, $nums[$i + $k - 1] - $nums[$i]);
163+
}
164+
return $rs;
165+
}
166+
}
167+
```
168+
149169
### **...**
150170

151171
```

‎solution/1900-1999/1984.Minimum Difference Between Highest and Lowest of K Scores/README_EN.md‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,26 @@ impl Solution {
136136
}
137137
```
138138

139+
### **PHP**
140+
141+
```php
142+
class Solution {
143+
/**
144+
* @param Integer[] $nums
145+
* @param Integer $k
146+
* @return Integer
147+
*/
148+
function minimumDifference($nums, $k) {
149+
sort($nums);
150+
$rs = 10 ** 5;
151+
for ($i = 0; $i < count($nums) - $k + 1; $i++) {
152+
$rs = min($rs, $nums[$i + $k - 1] - $nums[$i]);
153+
}
154+
return $rs;
155+
}
156+
}
157+
```
158+
139159
### **...**
140160

141161
```
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution {
2+
/**
3+
* @param Integer[] $nums
4+
* @param Integer $k
5+
* @return Integer
6+
*/
7+
function minimumDifference($nums, $k) {
8+
sort($nums);
9+
$rs = 10 ** 5;
10+
for ($i = 0; $i < count($nums) - $k + 1; $i++) {
11+
$rs = min($rs, $nums[$i + $k - 1] - $nums[$i]);
12+
}
13+
return $rs;
14+
}
15+
}

0 commit comments

Comments
(0)

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