diff --git a/EquilibriumIndex.php b/EquilibriumIndex.php index 020dd2b..4cbf38b 100644 --- a/EquilibriumIndex.php +++ b/EquilibriumIndex.php @@ -1,9 +1,46 @@ $v){ + # Remove the current element from the right sum + $sum_r -= $v; + # Check if left sum equals right sum and update output array + if($sum_l === $sum_r){ + $output[] = $k; + } + # Add the current element to the left sum + $sum_l += $v; + } + return $output; } -