You are viewing a single comment's thread. Return to all comments →
Your solution translated to JavaScript:
const dictionary = {}; let count = 0; for (let i = 0; i < str.length; i++) { for (let j = i + 1; j < str.length + 1; j++) { const transformed = str.slice(i, j).trim().split('').sort().join(''); if (dictionary[transformed]) { count += dictionary[transformed]; dictionary[transformed]++; } else { dictionary[transformed] = 1; } } } return count;
Seems like cookies are disabled on this browser, please enable them to open this website
Sherlock and Anagrams
You are viewing a single comment's thread. Return to all comments →
Your solution translated to JavaScript: