Skip to content

Latest commit

 

History

History
24 lines (14 loc) · 927 Bytes

Buying Show Tickets.md

File metadata and controls

24 lines (14 loc) · 927 Bytes

Screen Shot 2022-03-08 at 18 27 37

Screen Shot 2022-03-08 at 18 27 44

Screen Shot 2022-03-08 at 18 27 52

Screen Shot 2022-03-08 at 18 27 58

function waitingTime(tickets, p) {
    // Write your code here
    let totalTime = 0;
    for(const [pos, ticket] of tickets.entries()) {
        totalTime += Math.min(ticket, tickets[p] - (pos > p));
    }
        
    return totalTime;
}