Skip to content

Instantly share code, notes, and snippets.

@jatinsharrma
Last active February 16, 2020 11:12
Show Gist options
  • Save jatinsharrma/83971f9d5c586b26c6312557ed6db44c to your computer and use it in GitHub Desktop.
Save jatinsharrma/83971f9d5c586b26c6312557ed6db44c to your computer and use it in GitHub Desktop.
Designer PDF Viewer (Hackerrank)
#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