| Conditions | 4 |
| Paths | 4 |
| Total Lines | 17 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | public function solution($A) |
||
| 8 | { |
||
| 9 | $N = count($A); |
||
| 10 | if ($N) { |
||
| 11 | $count = array_count_values($A); |
||
| 12 | arsort($count); |
||
| 13 | foreach ($count as $key => $value) { |
||
| 14 | if ($value <= (int) ($N / 2)) { |
||
| 15 | return -1; |
||
| 16 | } else { |
||
| 17 | return array_search($key, $A); |
||
| 18 | } |
||
| 19 | } |
||
| 20 | } |
||
| 21 | |||
| 22 | return -1; |
||
| 23 | } |
||
| 24 | } |
||
| 25 |