image_2022-04-06_11-13-29.png
30.5 KB
#N2073. Time Needed to Buy Tickets
problem link
#solution
problem link
#solution
class Solution {
public int timeRequiredToBuy(int[] tickets, int k) {
int time=0;
while(tickets[k]!=0){
for(int i=0; i<tickets.length; i++){
if(tickets[i]-- > 0) time++;
if(tickets[k]==0) break;
}
}
return time;
}
}