728x90
https://leetcode.com/problems/time-needed-to-buy-tickets/
class Solution:
def timeRequiredToBuy(self, tickets: List[int], k: int) -> int:
seconds = 0
while tickets[k] > 0:
for i in range(len(tickets)):
if tickets[i] > 0:
tickets[i] -= 1
seconds += 1
if tickets[k] == 0:
break
return seconds
728x90
'IT > 코딩테스트' 카테고리의 다른 글
[Leetcode] 3114. Latest Time You Can Obtain After Replacing Characters (0) | 2024.04.14 |
---|---|
[Leetcode] 3110. Score of a String (0) | 2024.04.13 |
[Leetcode] 1700. Number of Students Unable to Eat Lunch (0) | 2024.04.08 |
[Leetcode] 678. Valid Parenthesis String (0) | 2024.04.07 |
[Leetcode] 1544. Make The String Great (0) | 2024.04.05 |