We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2fdbcab commit 588a3e1Copy full SHA for 588a3e1
Medium/Seat Reservation Manager.java
@@ -0,0 +1,28 @@
1
+class SeatManager {
2
+
3
+ PriorityQueue<Integer> pq;
4
+ int count;
5
6
+ public SeatManager(int n) {
7
+ pq = new PriorityQueue<>();
8
+ count = 1;
9
+ }
10
11
+ public int reserve() {
12
+ if (pq.size() == 0) {
13
+ return count++;
14
15
+ return pq.remove();
16
17
18
+ public void unreserve(int seatNumber) {
19
+ pq.add(seatNumber);
20
21
+}
22
23
+/**
24
+ * Your SeatManager object will be instantiated and called as such:
25
+ * SeatManager obj = new SeatManager(n);
26
+ * int param_1 = obj.reserve();
27
+ * obj.unreserve(seatNumber);
28
+ */
0 commit comments