You are viewing a single comment's thread. Return to all comments →
import java.io.; import java.util.; import java.text.; import java.math.; import java.util.regex.*;
public class Solution {
public static void main(String[] args) { Scanner in = new Scanner(System.in); String s = in.next(); int n = in.nextInt(); int val[] = new int[n]; for(int a0 = 0; a0 < n; a0++){ int x = in.nextInt(); // your code goes here val[a0] = x; } int result = 0; int temp = 0; Set<Integer> arr = new HashSet<Integer>(); for(int i=0;i<s.length();i++) { if(i>0 && s.charAt(i-1) == s.charAt(i)) { temp = temp + s.charAt(i) - 97 + 1; result = temp; } else { result = s.charAt(i) - 97 + 1; temp = result; } arr.add(result); result = 0; } for(int i=0;i<n;i++) { if (arr.contains(val[i])) System.out.println("Yes"); else System.out.println("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 →
import java.io.; import java.util.; import java.text.; import java.math.; import java.util.regex.*;
public class Solution {
}