You are viewing a single comment's thread. Return to all comments →
Here is a bit cleaner version:
function weightedUniformStrings(s, queries) { const weights = new Set() let sum = 0 for (let i = 0; i < s.length; i++) { if (s[i-1] !== s[i]) sum = 0 sum += s[i].charCodeAt(0) - 97 + 1 weights.add(sum) } return queries.map(val => (weights.has(val) ? 'Yes' : 'No')) }
Seems like cookies are disabled on this browser, please enable them to open this website
Weighted Uniform Strings
You are viewing a single comment's thread. Return to all comments →
Here is a bit cleaner version: