| Conditions | 4 |
| Paths | 4 |
| Total Lines | 15 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 32 | public static function heightChecker2(array $heights): int |
||
| 33 | { |
||
| 34 | if (empty($heights)) { |
||
| 35 | return 0; |
||
| 36 | } |
||
| 37 | $ordered = $heights; |
||
| 38 | sort($ordered); |
||
| 39 | [$cnt, $n] = [0, count($heights)]; |
||
| 40 | for ($i = 0; $i < $n; $i++) { |
||
| 41 | if ($ordered[$i] !== $heights[$i]) { |
||
| 42 | $cnt++; |
||
| 43 | } |
||
| 44 | } |
||
| 45 | |||
| 46 | return $cnt; |
||
| 47 | } |
||
| 49 |