diff --git a/solution/1400-1499/1431.Kids With the Greatest Number of Candies/README.md b/solution/1400-1499/1431.Kids With the Greatest Number of Candies/README.md index 6947c3a1821d9..b8087ea992072 100644 --- a/solution/1400-1499/1431.Kids With the Greatest Number of Candies/README.md +++ b/solution/1400-1499/1431.Kids With the Greatest Number of Candies/README.md @@ -164,6 +164,26 @@ bool *kidsWithCandies(int *candies, int candiesSize, int extraCandies, int *retu } ``` +### **PHP** + +```php +class Solution { + /** + * @param Integer[] $candies + * @param Integer $extraCandies + * @return Boolean[] + */ + function kidsWithCandies($candies, $extraCandies) { + $max = max($candies); + $rs = []; + for ($i = 0; $i < count($candies); $i++) { + array_push($rs, $candies[$i] + $extraCandies>= $max); + } + return $rs; + } +} +``` + ### **...** ``` diff --git a/solution/1400-1499/1431.Kids With the Greatest Number of Candies/README_EN.md b/solution/1400-1499/1431.Kids With the Greatest Number of Candies/README_EN.md index a4e4a27007ce3..40bb6e26caa42 100644 --- a/solution/1400-1499/1431.Kids With the Greatest Number of Candies/README_EN.md +++ b/solution/1400-1499/1431.Kids With the Greatest Number of Candies/README_EN.md @@ -161,6 +161,26 @@ bool *kidsWithCandies(int *candies, int candiesSize, int extraCandies, int *retu } ``` +### **PHP** + +```php +class Solution { + /** + * @param Integer[] $candies + * @param Integer $extraCandies + * @return Boolean[] + */ + function kidsWithCandies($candies, $extraCandies) { + $max = max($candies); + $rs = []; + for ($i = 0; $i < count($candies); $i++) { + array_push($rs, $candies[$i] + $extraCandies>= $max); + } + return $rs; + } +} +``` + ### **...** ``` diff --git a/solution/1400-1499/1431.Kids With the Greatest Number of Candies/Solution.php b/solution/1400-1499/1431.Kids With the Greatest Number of Candies/Solution.php new file mode 100644 index 0000000000000..65b023ddb2927 --- /dev/null +++ b/solution/1400-1499/1431.Kids With the Greatest Number of Candies/Solution.php @@ -0,0 +1,15 @@ +class Solution { + /** + * @param Integer[] $candies + * @param Integer $extraCandies + * @return Boolean[] + */ + function kidsWithCandies($candies, $extraCandies) { + $max = max($candies); + $rs = []; + for ($i = 0; $i < count($candies); $i++) { + array_push($rs, $candies[$i] + $extraCandies>= $max); + } + return $rs; + } +} \ No newline at end of file