You are viewing a single comment's thread. Return to all comments →
Javascript
function number_needed(a, b) { let count = 0; let freq = new Array(26).fill(0); const inc = (c, i) => freq[c.charCodeAt(0) - 'a'.charCodeAt(0)] += i; for (let c of a) inc(c, 1); for (let c of b) inc(c, -1); for (let v of freq) count += Math.abs(v); return count; }
Strings: Making Anagrams
You are viewing a single comment's thread. Return to all comments →
Javascript