A theater booking page has rows numbered 1 to n. Each group booking [first, last, seats] reserves seats seats in every row from first to last, both included.
Write seatsPerRow(n, bookings) that returns an array of length n where item i is the total seats reserved in row i + 1.
Input: n = 4, bookings = [[1,3,5],[2,4,2],[4,4,7]] Output: [5,7,7,9]
Row 2 gets 5 and 2 seats; row 4 gets 2 and 7 seats.
Input: n = 3, bookings = [] Output: [0,0,0]
No bookings, so every row is empty.
1 <= n <= 10^50 <= bookings.length <= 10^51 <= first <= last <= n1 <= seats <= 10^4Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #55 Seat Bookings per Row. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.