A concert hall has n rows numbered from 0 to n - 1, each with m seats, numbered from 0 to m - 1. You need to design a ticketing system that can allocate seats in the following cases:
k spectators can sit together in a row.k spectators can get a seat. They may or may not sit together.Note that the spectators are very picky. Hence:
maxRow. maxRow can vary from group to group.Implement the BookMyShow class:
BookMyShow(int n, int m) Initializes the object with n as the number of rows and m as the number of seats per row.int[] gather(int k, int maxRow) Returns an array of length 2 denoting the row and seat number (respectively) of the first seat being allocated to the k members of the group, who must sit together. In other words, it returns the smallest possible r and c such that all [c, c + k - 1] seats are valid and empty in row r, and r <= maxRow. Returns [] if it is not possible to allocate seats to the group.boolean scatter(int k, int maxRow) Returns true if all k members of the group can be allocated seats in rows 0 to maxRow, who may or may not sit together. If the seats can be allocated, it allocates k seats to the group with the smallest row numbers, and the smallest possible seat numbers in each row. Otherwise, returns false.1 <= n <= 5 * 10^41 <= m, k <= 10^90 <= maxRow <= n - 15 * 10^4 calls in total will be made to gather and scatter.["BookMyShow", "gather", "gather", "scatter", "scatter"]
[[2, 5], [4, 0], [2, 0], [5, 1], [5, 1]]
[null, [0, 0], [], true, false]