Python | Easy
see the Successfully Accepted Submission\n\n# Code\n\nclass Solution:\n    def timeRequiredToBuy(self, tickets: List[int], k: int) -> int:\n        n = len(tick
[see the Successfully Accepted Submission](https://leetcode.com/problems/time-needed-to-buy-tickets/submissions/1227409140/?source=submission-ac)\n\n# Code\n```\nclass Solution:\n    def timeRequiredToBuy(self, tickets: List[int], k: int) -> int:\n        n = len(tickets)\n        time = 0\n        \n        # Simulate the process\n        while tickets[k] > 0:\n            for i in range(n):\n                if tickets[i] > 0:\n                    tickets[i] -= 1\n                    time += 1\n                    if i == k and tickets[i] == 0:\n                        return time\n        return time\n        \n```\n\n![image](https://assets.leetcode.com/users/images/b1e4af48-4da1-486c-bc97-b11ae02febd0_1696186577.992237.jpeg)
['Python3']