diff --git a/solution/1400-1499/1475.Final Prices With a Special Discount in a Shop/README.md b/solution/1400-1499/1475.Final Prices With a Special Discount in a Shop/README.md index bf0c322bde844..9d926bdbca47c 100644 --- a/solution/1400-1499/1475.Final Prices With a Special Discount in a Shop/README.md +++ b/solution/1400-1499/1475.Final Prices With a Special Discount in a Shop/README.md @@ -370,6 +370,28 @@ impl Solution { } ``` +### **PHP** + +```php +class Solution { + /** + * @param Integer[] $prices + * @return Integer[] + */ + function finalPrices($prices) { + for ($i = 0; $i < count($prices); $i++) { + for ($j = $i + 1; $j < count($prices); $j++) { + if ($prices[$i] >= $prices[$j]) { + $prices[$i] -= $prices[$j]; + break; + } + } + } + return $prices; + } +} +``` + ### **...** ``` diff --git a/solution/1400-1499/1475.Final Prices With a Special Discount in a Shop/README_EN.md b/solution/1400-1499/1475.Final Prices With a Special Discount in a Shop/README_EN.md index 71b15a808eca6..8406eba67118a 100644 --- a/solution/1400-1499/1475.Final Prices With a Special Discount in a Shop/README_EN.md +++ b/solution/1400-1499/1475.Final Prices With a Special Discount in a Shop/README_EN.md @@ -341,6 +341,28 @@ impl Solution { } ``` +### **PHP** + +```php +class Solution { + /** + * @param Integer[] $prices + * @return Integer[] + */ + function finalPrices($prices) { + for ($i = 0; $i < count($prices); $i++) { + for ($j = $i + 1; $j < count($prices); $j++) { + if ($prices[$i] >= $prices[$j]) { + $prices[$i] -= $prices[$j]; + break; + } + } + } + return $prices; + } +} +``` + ### **...** ``` diff --git a/solution/1400-1499/1475.Final Prices With a Special Discount in a Shop/Solution.php b/solution/1400-1499/1475.Final Prices With a Special Discount in a Shop/Solution.php new file mode 100644 index 0000000000000..02932132d6895 --- /dev/null +++ b/solution/1400-1499/1475.Final Prices With a Special Discount in a Shop/Solution.php @@ -0,0 +1,17 @@ +class Solution { + /** + * @param Integer[] $prices + * @return Integer[] + */ + function finalPrices($prices) { + for ($i = 0; $i < count($prices); $i++) { + for ($j = $i + 1; $j < count($prices); $j++) { + if ($prices[$i] >= $prices[$j]) { + $prices[$i] -= $prices[$j]; + break; + } + } + } + return $prices; + } +} \ No newline at end of file