Single Pass | Python
Complexity\n- Time complexity: O(n)\n\n- Space complexity: O(1)\n\n# Code\n\nclass Solution:\n    def timeRequiredToBuy(self, tickets: List[int], k: int) -> int
# Complexity\n- Time complexity: O(n)\n\n- Space complexity: O(1)\n\n# Code\n```\nclass Solution:\n    def timeRequiredToBuy(self, tickets: List[int], k: int) -> int:\n        ans = 0\n        for i in range(k+1):\n            ans+=min(tickets[i],tickets[k])\n\n        for i in range(k+1,len(tickets)):\n            ans+=min(tickets[i],tickets[k]-1)\n\n        return ans\n\n        \n```
['Python3']