1234567891011121314151617 |
- <?php
- function comp($a = [], $b = []): bool {
- // Protect against degenerate cases using invalid arguments.
- if (gettype($a) !== gettype($b) || count($a) != count($b)) {
- return false;
- }
- sort($a);
- sort($b);
- for ($i = 0; $i < count($a); $i++) {
- $x = $a[$i]*$a[$i];
- if ($x != $b[$i]) {
- return false;
- }
- }
- return true;
- }
|