From e2dada147437c4acfe2a242c4d23af3f33c135df Mon Sep 17 00:00:00 2001 From: Qiu-IT Date: Wed, 19 Jul 2023 12:00:45 +0200 Subject: [PATCH] feat: add php solution to LCP: No.06 --- .../README.md" | 18 ++++++++++++++++++ .../Solution.php" | 13 +++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 "lcp/LCP 06. \346\213\277\347\241\254\345\270\201/Solution.php" diff --git "a/lcp/LCP 06. \346\213\277\347\241\254\345\270\201/README.md" "b/lcp/LCP 06. \346\213\277\347\241\254\345\270\201/README.md" index 40f157d355561..7a7bbda366870 100644 --- "a/lcp/LCP 06. \346\213\277\347\241\254\345\270\201/README.md" +++ "b/lcp/LCP 06. \346\213\277\347\241\254\345\270\201/README.md" @@ -116,6 +116,24 @@ function minCount(coins: number[]): number { } ``` +### **PHP** + +```php +class Solution { + /** + * @param Integer[] $coins + * @return Integer + */ + function minCount($coins) { + $cnt = 0; + for ($i = 0; $i < count($coins); $i++) { + $cnt += floor($coins[$i] / 2) + ($coins[$i] % 2); + } + return $cnt; + } +} +``` + ### **...** ``` diff --git "a/lcp/LCP 06. \346\213\277\347\241\254\345\270\201/Solution.php" "b/lcp/LCP 06. \346\213\277\347\241\254\345\270\201/Solution.php" new file mode 100644 index 0000000000000..eb3342d0efaf1 --- /dev/null +++ "b/lcp/LCP 06. \346\213\277\347\241\254\345\270\201/Solution.php" @@ -0,0 +1,13 @@ +class Solution { + /** + * @param Integer[] $coins + * @return Integer + */ + function minCount($coins) { + $cnt = 0; + for ($i = 0; $i < count($coins); $i++) { + $cnt += floor($coins[$i] / 2) + ($coins[$i] % 2); + } + return $cnt; + } +}