Leetcode in Java && Oracle
422 subscribers
8 photos
397 files
400 links
Second channel: @codeforces_java

Let's Develop Together!
Download Telegram
image_2022-04-06_11-13-29.png
30.5 KB
#N2073. Time Needed to Buy Tickets
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;
}
}