Easiest Solution without using Queue || C++ || Beginner Approach
\n\n\n# Code\n\nclass Solution {\npublic:\n    int timeRequiredToBuy(vector<int>& tickets, int k) {\n        int n=tickets.size();\n        int sum=0;\n\n      
![Screenshot from 2024-04-09 14-19-07.png](https://assets.leetcode.com/users/images/9f703e90-21c5-495b-8144-83b294ebc96f_1712652564.0821893.png)\n\n\n# Code\n```\nclass Solution {\npublic:\n    int timeRequiredToBuy(vector<int>& tickets, int k) {\n        int n=tickets.size();\n        int sum=0;\n\n        for(int i=0;i<n;i++){\n            if(tickets[i]<=tickets[k]){\n                sum=sum+tickets[i];\n            }\n            else if(tickets[i]>tickets[k]){\n                sum=sum+tickets[k];\n            }\n        }\n        for(int i=k+1;i<n;i++){\n            if(tickets[i]>=tickets[k]){\n                sum=sum-1;\n            }\n        }\n        return sum;\n    }\n};\n```
['C++']