RemoveElement   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
eloc 8
c 2
b 0
f 0
dl 0
loc 16
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A removeElement() 0 14 4
1
<?php
2
3
declare(strict_types=1);
4
5
namespace leetcode;
6
7
class RemoveElement
8
{
9
    public static function removeElement(array &$nums, int $value): int
10
    {
11
        if (($n = count($nums)) === 0) {
12
            return 0;
13
        }
14
15
        $j = 0;
16
        for ($i = 0; $i < $n; $i++) {
17
            if ($nums[$i] !== $value) {
18
                $nums[$j++] = $nums[$i];
19
            }
20
        }
21
22
        return $j;
23
    }
24
}
25