Biggest Digit Product
Imagine a long string of digits as a tape with a window of length k moving across it. For each window, multiply all digits inside it and look for the largest product. Write a function largest_series_product that returns the maximum product among all groups of k consecutive digits in digits.
Примеры
Ввод
"12345", 2Вывод
20Ввод
"1027839564", 3Вывод
270Ввод
"73167176531330624919225119674426574742355349194934", 6Вывод
23520Нужно реализовать
def largest_series_product(digits: str, k: int) -> int:
Теги
stringssliding-window
Kirjaudu sisään nähdäksesi palautushistorian
Kirjaudu sisäänKirjaudu sisään käyttääksesi tekoälymentoria
Kirjaudu sisäänVisible tests
1
Input
"12345", 2Expected
202
Input
"1027839564", 3Expected
2703
Input
"73167176531330624919225119674426574742355349194934", 6Expected
235204
Input
"99099", 2Expected
815
Input
"00000", 3Expected
06
Input
"123", 3Expected
6Focus radio
Paused · SomaFM · Fluid