Simple logic🔥🔥🔥|| Very Easy Solution 🔥🔥🔥|| Beat 100% users🔥✅✅🔥
Intuition\nThe problem seems to be related to purchasing tickets from a particular position in a queue. The goal is to determine the total time required to buy 
# Intuition\nThe problem seems to be related to purchasing tickets from a particular position in a queue. The goal is to determine the total time required to buy all the tickets, given the number of tickets available at each position in the queue\n\n# Approach\nThe approach used in the provided code is to iterate through the queue, considering each position. For each position, it calculates the time required to buy the tickets based on the number of tickets available at that position and at position k. It uses Math.min() to select the minimum between the tickets available at the current position and at position k, then accumulates this time in the variable second. The loop continues until all positions in the queue are visited.\n\n# Complexity\n- Time complexity:\n $$O(n)$$ \n\n- Space complexity:\n$$O(1r)$$ \n\n# Code\n```\nclass Solution {\n    public int timeRequiredToBuy(int[] tickets, int k) {\n        int second=0;\n        for(int i=0;i<tickets.length;i++)\n        {\n            if(i<=k)\n            {\n                second=second+Math.min(tickets[i],tickets[k]);\n            }\n            else\n            {\n                 second=second+Math.min(tickets[i],tickets[k]-1);\n            }\n        }\n        return second;\n        \n    }\n}\n```
['Java']