Designer PDF Viewer

 Question :-

https://www.hackerrank.com/challenges/designer-pdf-viewer/problem

Solution in C++ language :-

#include <bits/stdc++.h>

using namespace std;

int main(){
    int a[26],i;
    string s;
    for(i=0;i<26;i++)
        cin>>a[i];
    
    cin>>s;
    int l=s.length();
    int t,p=0;
    for(i=0;i<l;i++){
        char c=s[i];
        t=int(c);
        t=t-97;
        if(a[t]>p)
            p=a[t];
    }
    cout<<p*l;
    

    return 0;
}

Comments

Popular posts from this blog

Sherlock and Squares

Cut The Sticks

Home