-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathE0018.cpp
More file actions
37 lines (33 loc) · 717 Bytes
/
E0018.cpp
File metadata and controls
37 lines (33 loc) · 717 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
Problem Statement: https://www.hackerrank.com/challenges/designer-pdf-viewer/problem
*/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
int designerPdfViewer(vector<int> h, string word) {
for(char &c : word)
c -= 97;
set<int> letters(word.begin(),word.end());
vector<int> arr;
for(auto itr=letters.begin() ; itr != letters.end() ; itr++)
arr.push_back(h[*itr]);
int max = *max_element(arr.begin(),arr.end());
return max*word.length();
}
int main()
{
int num;
string word;
vector<int> h;
for(int i=1 ; i<=26 ; i++){
cin>>num;
h.push_back(num);
}
cin.ignore();
getline(cin,word);
cout<<designerPdfViewer(h,word);
return 0;
}