You are viewing a single comment's thread. Return to all comments →
My solution in C:
#include <math.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <assert.h> #include <limits.h> #include <stdbool.h> int main(){ int *h = malloc(sizeof(int) * 26); for(int h_i = 0; h_i < 26; h_i++){ scanf("%d",&h[h_i]); } char* word = (char *)malloc(512000 * sizeof(char)); scanf("%s",word); int max = 0; size_t len = strlen(word); for(size_t i = 0; i < len; i++) { int ind = word[i] - 'a'; if(h[ind] > max) { max = h[ind]; } } printf("%d\n", max * len); return 0; }
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 →
My solution in C: