| 12345678910111213141516171819202122 |
- <?php
-
- namespace App\Services;
-
- class Helper
- {
- public static function addPrevValue(array $h): array
- {
- $i = [];
-
- for ($j = 0; $j <= count($h) - 1; $j++) {
- if ($j === 0) {
- array_push($i, $h[$j]);
- } else {
- array_push($i, $i[$j - 1] + $h[$j]);
- }
- }
-
- return $i;
- }
- }
|