From 12d52d9b1c3cd1eda4921b61cc67f88638f3c173 Mon Sep 17 00:00:00 2001 From: Qiu-IT Date: Wed, 14 Jun 2023 09:46:39 +0200 Subject: [PATCH] feat: add php solution to lc problem: No.1732 --- .../1732.Find the Highest Altitude/README.md | 19 +++++++++++++++++++ .../README_EN.md | 19 +++++++++++++++++++ .../Solution.php | 14 ++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 solution/1700-1799/1732.Find the Highest Altitude/Solution.php diff --git a/solution/1700-1799/1732.Find the Highest Altitude/README.md b/solution/1700-1799/1732.Find the Highest Altitude/README.md index d16047d5a106f..6bb96434ea946 100644 --- a/solution/1700-1799/1732.Find the Highest Altitude/README.md +++ b/solution/1700-1799/1732.Find the Highest Altitude/README.md @@ -179,6 +179,25 @@ int largestAltitude(int *gain, int gainSize) { } ``` +### **PHP** + +```php +class Solution { + /** + * @param Integer[] $gain + * @return Integer + */ + function largestAltitude($gain) { + $max = 0; + for ($i = 0; $i < count($gain); $i++) { + $tmp += $gain[$i]; + if ($tmp > $max) $max = $tmp; + } + return $max; + } +} +``` + ### **...** ``` diff --git a/solution/1700-1799/1732.Find the Highest Altitude/README_EN.md b/solution/1700-1799/1732.Find the Highest Altitude/README_EN.md index e559a1d0c00bf..6b035f2bd5c41 100644 --- a/solution/1700-1799/1732.Find the Highest Altitude/README_EN.md +++ b/solution/1700-1799/1732.Find the Highest Altitude/README_EN.md @@ -149,6 +149,25 @@ int largestAltitude(int *gain, int gainSize) { } ``` +### **PHP** + +```php +class Solution { + /** + * @param Integer[] $gain + * @return Integer + */ + function largestAltitude($gain) { + $max = 0; + for ($i = 0; $i < count($gain); $i++) { + $tmp += $gain[$i]; + if ($tmp > $max) $max = $tmp; + } + return $max; + } +} +``` + ### **...** ``` diff --git a/solution/1700-1799/1732.Find the Highest Altitude/Solution.php b/solution/1700-1799/1732.Find the Highest Altitude/Solution.php new file mode 100644 index 0000000000000..fe6641670bc9a --- /dev/null +++ b/solution/1700-1799/1732.Find the Highest Altitude/Solution.php @@ -0,0 +1,14 @@ +class Solution { + /** + * @param Integer[] $gain + * @return Integer + */ + function largestAltitude($gain) { + $max = 0; + for ($i = 0; $i < count($gain); $i++) { + $tmp += $gain[$i]; + if ($tmp > $max) $max = $tmp; + } + return $max; + } +} \ No newline at end of file