💯JAVA Solution Explained in HINDI
https://youtu.be/mAWSTUdCb_s\n\nFor explanation, please watch the above video and do like, share and subscribe the channel. \u2764\uFE0F Also, please do upvote 
https://youtu.be/mAWSTUdCb_s\n\nFor explanation, please watch the above video and do like, share and subscribe the channel. \u2764\uFE0F Also, please do upvote the solution if you liked it.\n\nSubscribe link:- [ReelCoding](https://www.youtube.com/@reelcoding?sub_confirmation=1)\n\nSubscribe Goal:- 400\nCurrent Subscriber:- 303\n# 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```\nclass Solution {\n    public int timeRequiredToBuy(int[] tickets, int k) {\n        \n        int time = 0;\n\n        for(int i = 0; i < tickets.length; i++) {\n\n            if(i <= k) {\n                time += Math.min(tickets[k], tickets[i]);\n            }\n            else {\n                time += Math.min(tickets[k] - 1, tickets[i]);\n            }\n        }\n        return time;\n    }\n}\n```
['Java']