Highlighted Word Area
In a PDF viewer, a word is highlighted with a rectangle, and its area depends on the tallest letter in the word. The function designer_pdf_viewer receives a list h of 26 heights for the letters a through z, and a lowercase word word. The rectangle height is the maximum letter height in the word, and its width is the number of letters. Return the area of that rectangle.
Примеры
Ввод
[1, 3, 1, 3, 1, 4, 1, 3, 2, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 7], "abc"Вывод
9Ввод
[1, 3, 1, 3, 1, 4, 1, 3, 2, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 7], "zaba"Вывод
28Ввод
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], "hello"Вывод
5Нужно реализовать
def designer_pdf_viewer(h: list[int], word: str) -> int:
Теги
arraystrings
Kirjaudu sisään nähdäksesi palautushistorian
Kirjaudu sisäänKirjaudu sisään käyttääksesi tekoälymentoria
Kirjaudu sisäänVisible tests
1
Input
[1,3,1,3,1,4,1,3,2,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,7], "abc"Expected
92
Input
[1,3,1,3,1,4,1,3,2,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,7], "zaba"Expected
283
Input
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1], "hello"Expected
54
Input
[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2], "a"Expected
25
Input
[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26], "abc"Expected
96
Input
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1], "ab"Expected
2Focus radio
Paused · SomaFM · Fluid