You are viewing a single comment's thread. Return to all comments →
function weightedUniformStrings(s: string, queries: number[]): string[] { const alphabet = '0abcdefghijklmnopqrstuvwxyz'.split(''); const availWeights = new Set<number>() const chop = s.split('') let mult = 1 for(let i = 0; i < chop.length; i++) { const weight = alphabet.indexOf(chop[i]) * mult; availWeights.add(weight); if(chop[i+1] !== chop[i]) { mult = 1 } else { mult++ } } const result: string[] = [] for(let query of queries) { availWeights.has(query) ? result.push('Yes') : result.push('No') } return result }
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 →