Open jzhangnu opened 7 years ago
var exist = function(board, word) { board = board.reduce(function(counted, e){ return counted.concat(e); }) var i = 0, hash = {}; board.forEach(function(e){ if(hash[e])hash[e]++; else hash[e] = 1; }) word.split('').forEach(function(e){ if(hash[e])hash[e]--; else return false }) return true };
Oh my!!! This is so simple and effective...Please can you explain this, I have been struggling with this for a while now