| Conditions | 7 |
| Paths | 10 |
| Total Lines | 24 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | public function solution($S) |
||
| 8 | { |
||
| 9 | $length = strlen($S); |
||
| 10 | if ($length) { |
||
| 11 | $parentheses = []; |
||
| 12 | for ($i = 0; $i < $length; $i++) { |
||
| 13 | if ($S[$i] == '(') { |
||
| 14 | array_push($parentheses, '('); |
||
| 15 | } elseif ($S[$i] == ')') { |
||
| 16 | if (empty($parentheses)) { |
||
| 17 | return 0; |
||
| 18 | } |
||
| 19 | array_pop($parentheses); |
||
| 20 | } |
||
| 21 | } |
||
| 22 | if (empty($parentheses)) { |
||
| 23 | return 1; |
||
| 24 | } else { |
||
| 25 | return 0; |
||
| 26 | } |
||
| 27 | } |
||
| 28 | |||
| 29 | return 1; |
||
| 30 | } |
||
| 31 | } |
||
| 32 |