From 19a62b20c7058bec4ec89f8879e49025e0ce9881 Mon Sep 17 00:00:00 2001 From: Sarvar <56576654+sarvar-akbarov@users.noreply.github.com> Date: Sun, 2 Jul 2023 19:08:45 +0500 Subject: [PATCH] Added solution in PHP language --- solutions/034.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/solutions/034.md b/solutions/034.md index d93b552..6574b8b 100644 --- a/solutions/034.md +++ b/solutions/034.md @@ -59,6 +59,7 @@ To summarize: The algorithm has a time complexity that grows logarithmically with the number of points. It is efficient for processing a moderate number of points, but as the number of points increases significantly, the sorting step becomes more time-consuming. +#### Python3 ```python3 class Solution: def maxWidthOfVerticalArea(self, points: List[List[int]]) -> int: @@ -69,4 +70,28 @@ class Solution: return maximum ``` +#### PHP +```php +class Solution { + + /** + * @param Integer[][] $points + * @return Integer + */ + function maxWidthOfVerticalArea($points) { + usort($points, function($a, $b){ + return $a[0] > $b[0] ? 1 : -1; + }); + + $max = 0; + $n = count($points); + for($i = 0; $i < $n - 1; $i++){ + $max = max($max, $points[$i + 1][0] - $points[$i][0]); + } + + return $max; + } +} +``` + ***NB***: If you want to get community points please suggest solutions in other languages as merge requests.