You are viewing a single comment's thread. Return to all comments →
javascript
function checkMagazine(magazine, note) { let map = new Map() for (let i = 0; i < magazine.length; i++) { if (map.has(magazine[i])) map.set(magazine[i], map.get(magazine[i] + 1)) else map.set(magazine[i], 1) } for (let i = 0; i < note.length; i++) { if (map.has(note[i]) && map.get(note[i]) > 0) map.set(note[i], map.get(note[i]) - 1) else { console.log('No') return } } console.log('Yes') }
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