From b38ea7a89eacdd420e975878b6b6ec90eafb2b29 Mon Sep 17 00:00:00 2001 From: Qiu-IT Date: Mon, 5 Jun 2023 09:37:48 +0200 Subject: [PATCH] feat:add php solution to lc problem: No.1475 --- .../README.md | 22 +++++++++++++++++++ .../README_EN.md | 22 +++++++++++++++++++ .../Solution.php | 17 ++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 solution/1400-1499/1475.Final Prices With a Special Discount in a Shop/Solution.php 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