Is it possible to solve this problem with bit manipulation?


  • 0
    public boolean isAnagram(String s, String t) {
        if(s.length() != t.length())
            return false;
        int res = 0;
        for(int i=0; i < s.length(); i++ )
            res = res ^ s.charAt(i) ^ t.charAt(i);
        return res == 0;
    }
    

    It can't pass the case "aa", "bb". Any ideas?


  • 0
    K
    This post is deleted!

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.