Leetcode 2195 Solution
This article provides solution to leetcode question 2195 (time-needed-to-buy-tickets)
Access this page by simply typing in "lcs 2195" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/time-needed-to-buy-tickets
Solution
class Solution:
def timeRequiredToBuy(self, tickets: List[int], k: int) -> int:
ans = 0
for i, ticket in enumerate(tickets):
if i <= k:
ans += min(tickets[k], ticket)
else:
ans += min(tickets[k] - 1, ticket)
return ans