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 de2fcb9

Browse files
authored
feat: add php solution to lc problem: No.1431 (#1017)
1 parent 485a4b9 commit de2fcb9

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

‎solution/1400-1499/1431.Kids With the Greatest Number of Candies/README.md‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,26 @@ bool *kidsWithCandies(int *candies, int candiesSize, int extraCandies, int *retu
164164
}
165165
```
166166
167+
### **PHP**
168+
169+
```php
170+
class Solution {
171+
/**
172+
* @param Integer[] $candies
173+
* @param Integer $extraCandies
174+
* @return Boolean[]
175+
*/
176+
function kidsWithCandies($candies, $extraCandies) {
177+
$max = max($candies);
178+
$rs = [];
179+
for ($i = 0; $i < count($candies); $i++) {
180+
array_push($rs, $candies[$i] + $extraCandies >= $max);
181+
}
182+
return $rs;
183+
}
184+
}
185+
```
186+
167187
### **...**
168188

169189
```

‎solution/1400-1499/1431.Kids With the Greatest Number of Candies/README_EN.md‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,26 @@ bool *kidsWithCandies(int *candies, int candiesSize, int extraCandies, int *retu
161161
}
162162
```
163163
164+
### **PHP**
165+
166+
```php
167+
class Solution {
168+
/**
169+
* @param Integer[] $candies
170+
* @param Integer $extraCandies
171+
* @return Boolean[]
172+
*/
173+
function kidsWithCandies($candies, $extraCandies) {
174+
$max = max($candies);
175+
$rs = [];
176+
for ($i = 0; $i < count($candies); $i++) {
177+
array_push($rs, $candies[$i] + $extraCandies >= $max);
178+
}
179+
return $rs;
180+
}
181+
}
182+
```
183+
164184
### **...**
165185

166186
```
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[] $candies
4+
* @param Integer $extraCandies
5+
* @return Boolean[]
6+
*/
7+
function kidsWithCandies($candies, $extraCandies) {
8+
$max = max($candies);
9+
$rs = [];
10+
for ($i = 0; $i < count($candies); $i++) {
11+
array_push($rs, $candies[$i] + $extraCandies >= $max);
12+
}
13+
return $rs;
14+
}
15+
}

0 commit comments

Comments
(0)

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