JavaScript solution


  • 1
    L
    function isAnagram(s, t) {
    	const map = {};
    	s.split('').map(c => map[c] = map[c] ? map[c] + 1 : 1);
    	t.split('').map(c => map[c] = map[c] ? map[c] - 1 : -1);
    	return Object.keys(map).every(k => map[k] === 0);
    }

Log in to reply
 

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