0

Hello I'm new at coding I want to make my career as a coder and a web developer this is my code please help me to understand how we get maxheight

#include <bits/stdc++.h>
using namespace std;

    int main() {
        int height = -1,len,heights[26];
        string str;
        for(int i = 0; i < 26; i++)cin >> heights[i];
        cin >> str;
        len = str.length();
        for(int i = 0; i < len; i++){
            if(heights[str[i]-'a'] > height)height = heights[str[i]-'a'];
        }
        cout << len*height << endl;
        return 0;
    }

0 Answers0