You are viewing a single comment's thread. Return to all comments →
List<String> retList = new ArrayList<>(); List<Integer> sumList = new ArrayList<>(); String regex = "([a-z])\\1*"; Pattern p = Pattern.compile(regex); Matcher m = p.matcher(s); while(m.find()){ String sub = m.group(); char curr = sub.charAt(0); int count = sub.length(); for(int i=0;i<count;i++){ sumList.add(((int)curr-97+1)*(i+1)); } s=s.replace(sub,""); } for(int i=0;i<queries.size();i++){ if(sumList.contains(queries.get(i))){ retList.add("Yes"); }else{ retList.add("No"); } } return retList;
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 →