C++ Solution || Beats 100 % || Easy to Understand and Easy Solution
Intuition\nWe have to just keep decreasing 1 from each element.\n\n# Approach\n1. We will traverse the array and keep decreasing 1 from every element till the e
# Intuition\nWe have to just keep decreasing 1 from each element.\n\n# Approach\n1. We will traverse the array and keep decreasing 1 from every element till the element at kth position gets 0.\n2. We will also keep a count variable to keep track of the steps required for kth element to reach 0.\n\n# Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(1)\n\n# Code\n```\nclass Solution {\npublic:\n    int timeRequiredToBuy(vector<int>& tickets, int k) {\n        int count = 0, i = 0;\n\n        while(tickets[k] != 0){\n            if(i == tickets.size()){\n                i = 0;\n            }\n            if(tickets[i] == 0){\n                i++;\n                continue;\n            }\n            tickets[i]--;\n            count++;\n            i++;\n        }\n\n        return count;\n    }\n};\n```
['Array', 'Queue', 'C++']