Wednesday, November 27, 2019

[LeetCode][PHP] #242 Valid Anagram

https://leetcode.com/problems/valid-anagram/

class Solution {
    function isAnagram($s, $t) {
        $a_s = str_split($s);
        $a_t = str_split($t);
        sort($a_s);
        sort($a_t);
        return implode('', $a_s) === implode('', $a_t);
    }
}

No comments:

Post a Comment