Last active
February 16, 2020 11:12
-
-
Save jatinsharrma/83971f9d5c586b26c6312557ed6db44c to your computer and use it in GitHub Desktop.
Designer PDF Viewer (Hackerrank)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Find question here: https://www.hackerrank.com/challenges/designer-pdf-viewer/problem?h_r=internal-search | |
def designerPdfViewer(h, word): | |
big = 0 | |
l_st = list(set(list(word))) | |
for ch in l_st: | |
val = ord(ch) - 97 | |
if h[val] > big: | |
big = h[val] | |
return len(word) * big | |
h = list(map(int, input().rstrip().split())) | |
word = input() | |
print(designerPdfViewer(h,word)) | |
#------------------another way-------------- | |
def designerPdfViewer(h, word): | |
return (len(word) * max(h[ord(l)-ord('a')] for l in word)) | |
h = list(map(int, input().rstrip().split())) | |
word = input() | |
print(designerPdfViewer(h,word)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment