---
# System prepended metadata

title: 2073. Time Needed to Buy Tickets
tags: [Leetcode, Easy]

---

# 2073. Time Needed to Buy Tickets
###### tags: `Leetcode` `Easy`
Link: https://leetcode.com/problems/time-needed-to-buy-tickets/description/
## Code
```java=
class Solution {
    public int timeRequiredToBuy(int[] tickets, int k) {
        int time = 0;
        for(int i=0; i<tickets.length; i++){
            if(i<=k){
                time += Math.min(tickets[i], tickets[k]);
            }
            else time += Math.min(tickets[i], tickets[k]-1);
        }
        return time;
    }
}
```