Beats 96.00% of golang submissions!


  • 0
    B
    func isAnagram(s string, t string) bool {
    	var xor, squaresum1, squaresum2 rune
    	for _, char := range s {
    		xor ^= char
    		squaresum1 += char * char
    	}
    	for _, char := range t {
    		xor ^= char
    		squaresum2 += char * char
    	}
    	return xor == 0 && squaresum1 == squaresum2
    }
    

  • 0
    B

    No extra space needed.


Log in to reply
 

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