People stand in a line; tickets[i] is how many tickets person i wants. Each second the front person buys one ticket then moves to the back if they still need more. Return the number of seconds until the person at position k finishes buying all their tickets. The input is JSON {tickets, k}.
Input: JSON {tickets, k}.
Output: Integer — the total seconds.
Input: {"tickets":[2,3,2],"k":2}
Output: 6
Explanation: Person 2 finishes after 6 seconds.Input: {"tickets":[5,1,1,1],"k":0}
Output: 8
Explanation: Person 0 needs 5 rounds.Input: {"tickets":[1],"k":0}
Output: 1
Explanation: One ticket, one second.1<=n<=1000<=k<n