You are viewing a single comment's thread. Return to all comments →
Javascript solution
var map = { }; var replicable = true; for ( var i of magazine ) { map[i] = (map[i] || 0) + 1; } for ( var i of ransom ) { map[i] = (map[i] || 0) - 1; } for ( var i in map ) { if ( map[i] < 0 ) { replicable = false; break; } } console.log(replicable ? 'Yes' : 'No');
Seems like cookies are disabled on this browser, please enable them to open this website
Hash Tables: Ransom Note
You are viewing a single comment's thread. Return to all comments →
Javascript solution