You are viewing a single comment's thread. Return to all comments →
A simple java code
public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = 26; int h[] = new int[n]; for(int h_i=0; h_i < n; h_i++){ h[h_i] = in.nextInt(); } String word = in.next(); int max=0; int length=word.length(); HashMap<Character,Integer> map=new HashMap<Character,Integer>(); int i=0; for(char ch='a';ch<='z';ch++) { map.put(ch,h[i]); i++; } for(int j=0;j<length;j++) { int val=map.get(word.charAt(j)); if(val>max) max=val; } System.out.println(max*length); }
Seems like cookies are disabled on this browser, please enable them to open this website
Designer PDF Viewer
You are viewing a single comment's thread. Return to all comments →
A simple java code