We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
publicstaticList<String>weightedUniformStrings(Strings,List<Integer>queries){// Write your code hereList<Integer>output=newArrayList<>();List<String>weight=newArrayList<>();intn=0;for(inti=0;i<s.length();i+=n){n=0;for(intj=i;j<s.length();j++){if(s.charAt(i)==s.charAt(j)){n++;}else{j=s.length();}}for(intj=1;j<n+1;j++){output.add(j*((int)s.charAt(i)%96));}}for(Integerinteger:queries){if(output.contains(integer)){weight.add("Yes");}else{weight.add("No");}}returnweight;}
Cookie support is required to access HackerRank
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 →