Clean golang solution
Complexity\n- Time complexity: O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(1)\n Add your space complexity here, e.g. O(n) \n\n# Co
# Complexity\n- Time complexity: $$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nfunc timeRequiredToBuy(tickets []int, k int) int {\n    result := 0\n    c := tickets[k]\n    for i, n := range tickets {\n        if i == k {\n            result += c\n        } else if i < k {\n            result += min(c, n)\n        } else {\n            result += min(c-1, n)\n        }\n    }\n\n    return result\n}\n```
['Go']