You are viewing a single comment's thread. Return to all comments →
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(); }
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
Seems like cookies are disabled on this browser, please enable them to open this website
I agree to HackerRank's Terms of Service and Privacy Policy.
Designer PDF Viewer
You are viewing a single comment's thread. Return to all comments →
Here is my c++ solution, you can watch the explanation here : https://youtu.be/tRUU2pSf8fI
python version: