Two simple solutions in Python3 || Queue DS || Inifinite looping
Intuition\nFollowing to the description of the problem, the task goal is to calculate min amount of time, that K- buyer needs to spend in order to buy tickets.\
# Intuition\nFollowing to the description of the problem, the task goal is to calculate **min amount of time**, that `K`- buyer needs to spend in order to buy tickets.\n\nSomehow we need to iterate over all buyers, reduce the current amount of tickets they\'re bying at the moment, shift the current buyer to **the END of a** `queue` and repeat the process.\n\n---\n\n- **Queue DS**\n\nIf you haven\'t already familiar with [Queue DS](https://en.wikipedia.org/wiki/Queue_(abstract_data_type)), just follow the link to know more!\n\n1. change `tickets` variable by initializing a `deque` and **map** `i` and `v` for current buyer, \n2. initialize `ans` variable and `while` loop, that\'ll iterate **infinitely**\n3. pop from `tickets` current buyer\n4. increment total amount `ans` \n5. check, if the current buyer has bought all of the tickets, and return `ans`\n6. otherwise, if he needs to buy **more** tickets, return him to the `tickets` queue\n\n```python\nclass Solution:\n    def timeRequiredToBuy(self, tickets: list[int], k: int) -> int:\n        tickets = deque([[i, v] for i, v in enumerate(tickets)])\n        ans = 0\n\n        while True:\n            i, v = tickets.popleft()\n            ans += 1\n\n            if i == k and v - 1 == 0:\n                return ans\n            \n            if v > 1:\n                tickets.append([i, v - 1])\n```\n# Complexity\n- Time complexity: **O(n)**, because of iterating infinitely over all `tickets` buyers\n\n- Space complexity: **O(n)**, to map indexes and values for `tickets`\n\n---\n\n- **Inifinite looping**\nThe approach is the same, but we **mutate** the initial values of `tickets`.\n\n# Code\n```\nclass Solution:\n    def timeRequiredToBuy(self, tickets: List[int], k: int) -> int:\n        i = ans = 0\n\n        while True:\n            if tickets[i]:\n                tickets[i] -= 1\n                ans += 1\n            if not tickets[i] and k == i:\n                return ans\n                \n            i = (i + 1) % len(tickets)\n\n```\n\n# Complexity\n- Time complexity: **O(n)**, because of iterating infinitely over all `tickets` buyers\n\n- Space complexity: **O(1)**, because we don\'t use extra space.\n
['Array', 'Queue', 'Python3']