• + 1 comment

    Here is my c++ solution, you can watch the explanation here : https://youtu.be/tRUU2pSf8fI

    int designerPdfViewer(vector<int> h, string word) {
        int mx = 0;
        for(int el : word) if(h[el - 'a'] > mx) mx = h[el - 'a'];
        return mx * 1 * word.size();
    }
    
    • + 0 comments

      python version:

      str_len = len(word)
      max_height = 0
      for i in range(str_len):
          curr_height = h[ord(word[i]) - ord('a')]
          max_height = max(max_height, curr_height)
      return str_len * max_height