-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhotelroom.py
More file actions
28 lines (24 loc) · 809 Bytes
/
hotelroom.py
File metadata and controls
28 lines (24 loc) · 809 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#Hotel Bookings Possible - interviewbit
#https://www.interviewbit.com/problems/hotel-bookings-possible/
'''A hotel manager has to process N advance bookings of rooms for the next season.
His hotel has C rooms. Bookings contain an arrival date and a departure date.
He wants to find out whether there are enough rooms in the hotel to satisfy the demand.'''
def roomavail(arr,dep,k):
arr.sort()
dep.sort()
n = len(arr)
i,j,c = 0,0,0
while(i<n and j<n):
if(arr[i]<dep[j]):
i += 1
c += 1
if(c > k):
return False
else:
j += 1
c -= 1
return True
arr = list(map(int,input().split()))
dep = list(map(int,input().split()))
k = int(input())
print(roomavail(arr,dep,k))