Process Airline Seat Requests
Updated
Problem statement
An airline stores the current state of every seat and a sequence of reservation or purchase requests.
- A request with value
1reserves a free seat. - A request with value
2purchases a free seat. - A person may also purchase a seat that the same person previously reserved.
- Every other request is ignored.
Process requests from the smallest request_id to the largest and return the final state of every seat.
Table schema
MySQL
Use the same input data with any supported language. Open the Schema tab in the editor to see the generated SQL setup or Pandas DataFrames.
seats
| Column | Type | Nullable | Description |
|---|---|---|---|
| seat_noPK | Integer | No | Unique seat number. |
| status | Integer | No | 0 is free, 1 is reserved, and 2 is purchased. |
| person_id | Integer | No | 0 for a free seat; otherwise the reserving or purchasing person. |
requests
| Column | Type | Nullable | Description |
|---|---|---|---|
| request_idPK | Integer | No | Processing order. |
| request | Integer | No | 1 reserves and 2 purchases. |
| seat_no | Integer | No | — |
| person_id | Integer | No | — |
Foreign key: seat_no → seats(seat_no)
Expected result
Your query or function must return these columns.
| Column | Type | Nullable | Description |
|---|---|---|---|
| seat_no | Integer | No | — |
| status | Integer | No | — |
| person_id | Integer | No | — |
Row order: must match exactly. Numeric tolerance: 0.
Constraints
- Every
requests.seat_noappears inseats. - For this exercise, assume each
request_idis unique and return seats in ascendingseat_noorder.
More Agoda Online Assessment questions
- Special Diameter EndpointsOA · Seen Nov 2025
- TV Series in a Production WindowOA · Seen Nov 2025
- Count One Groups by SizeOA · Seen Jul 2025
- Minimum Price With Discount CouponsOA · Seen Jul 2025
- Lexicographically Smallest Task QueueOA · Seen Jul 2025
- Highest-Ranked University by CountryOA · Seen Jun 2025
- Jump Game with Prime-3 StepsOA · Seen Jun 2025
- Team FormationOA · Seen Apr 2025
- Two-Core Process AssignmentOA · Seen Apr 2025
- Unique Digits in RangeOA · Seen Apr 2025
Similar questions at other companies
- Track the Book and Mark Final PnLMillennium · OAMillennium interview questions
- In-Memory Database Historical LookupAnthropic · OAAnthropic interview questions
- Nested Transaction Key-Value Store with Value CountsLyft · ONSITE INTERVIEWLyft interview questions
- Parquet-Like Columnar Format OperationsJump Trading · PHONE SCREENJump Trading interview questions
- Assign Student Grades from CSV MarksHartford Financial Services · ONSITE INTERVIEWHartford Financial Services interview questions
- Financial Account LedgerStripe · OA · PHONE SCREENStripe interview questions
- Organization Reputation After Employee DeparturesHSBC · OAHSBC interview questions
- Bank Accounts with Balance HistoryMeta · OAMeta interview questions
- Last Object Exit TimeIBM · OAIBM interview questions
- Capping Portfolio WeightsCapstone Investment Advisors · OA