Free written solution

Cinema Seat Allocation (LeetCode 1386): Solution and Explanation

A cinema has n rows of ten seats with aisles after seats 3 and 7. Given the reserved seats, place as many groups of four adjacent seats as possible, where a group may be split two and two by the middle aisle. With n = 3 and reservedSeats = [[1,2],[1,3],[1,8],[2,6],[3,1],[3,10]] the answer is 4.

Read the intuition, approach, code and complexity →