Company: ION

Difficulty: medium

Problem Statement

Implement a ticket service for a movie theater with n rows of seats, and m seats in each row. The service allocates seats among incoming booking requests. Implement the SeatReservation class with the following structure: Instance Variables: n : Integer representing the number of rows in the theater m : Integer representing the number of seats per row Constructor: SeatReservation(int n, int m) : Initializes the instance variables Methods: string reserve(int r, int k) : Attempts to reserve k adjacent seats in row r If seats are available, returns "Booked with seat number s" where s is the starting seat number If seats are not available, returns "Seats not available" Seats in a row are numbered 1 through m . A reservation always takes the lowest-numbered block of k adjacent free seats in the requested row. Requests are handled in order, and once seats are booked, they cannot be booked again. The system must keep track of all reservations throughout the series of requests. Example With n =

More ION OA questionsInterview experiences