#include<stdio.h>
#include<stdlib.h>
#include<assert.h>
#include<math.h>
#include<string.h>
int main()
{
    int h[26];
    for(int i=0;i<26;i++)
    {
        scanf("%d",&h[i]);
    }
    char*word=(char*)malloc(512000*sizeof(char));
    scanf("%s",word);
    int len=strlen(word);
    int t=h[word[0]-97];
    for(int i=1;i<len;i++)
    {
        if(t<h[word[i]-97])
        t=h[word[i]-97];
    }
    printf("%d",(t*len));
    return 0;
}
why are we allocating the space dynamically for the word?
ReplyDeletecan't we use " s[11]; gets(s); " to take string instead of calloc??
ReplyDelete