| Total Complexity | 11 |
| Total Lines | 45 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | class ValidAnagram |
||
| 8 | { |
||
| 9 | public static function isAnagram(string $s, string $t): bool |
||
| 10 | { |
||
| 11 | [$m, $n] = [strlen($s), strlen($t)]; |
||
| 12 | if ($m !== $n) { |
||
| 13 | return false; |
||
| 14 | } |
||
| 15 | $source = $target = []; |
||
| 16 | for ($i = 0; $i < $m; $i++) { |
||
| 17 | $source[] = $s[$i]; |
||
| 18 | } |
||
| 19 | for ($i = 0; $i < $n; $i++) { |
||
| 20 | $target[] = $t[$i]; |
||
| 21 | } |
||
| 22 | sort($source); |
||
| 23 | sort($target); |
||
| 24 | |||
| 25 | return $source === $target; |
||
| 26 | } |
||
| 27 | |||
| 28 | public static function isAnagram2(string $s, string $t): bool |
||
| 52 | } |
||
| 53 | } |
||
| 54 |