PermMissingElem   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 0
dl 0
loc 20
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A solution() 0 17 4
1
<?php
2
3
namespace Lesson01;
4
5
class PermMissingElem
6
{
7
    public function solution($A)
8
    {
9
        $missing = 1;
10
        $count = count($A);
11
        sort($A);
12
        for ($i = 0; $i < $count; $i++) {
13
            if ($A[$i] != $i + 1) {
14
                $missing = $i + 1;
15
                break;
16
            }
17
        }
18
        if ($i == $count) {
19
            $missing = $count + 1;
20
        }
21
22
        return $missing;
23
    }
24
}
25