You are in geekworld railway station. You are given train schedule as follows
	arrival_time array contains arrival time of each train
	departure_time array contains departure time of each train
	days array contains the particular day when the trains runs. Also each train arrive and departs on the same day
	You are also given number_of_platforms you have.
You have to tell  if it is possible to run all the trains with the given number of platforms such that no train has to wait.
Note: If 2 trains arrive and depart on the same time on the same day on the same platform then depart the train first then second train arrives. Also time in geekland does not follow 24 hr(HHMM) format. So time can be 2368 or 2398, here 2398 > 2368.
 
Example 1:
Input: n = 6 
arr[] = {900, 940, 950, 1100, 1500, 1800}
dep[] = {910, 1200, 1120, 1130, 1900, 2000}
days[] = {1, 2, 2, 1, 3, 4}
platforms = 2
Output: True
Explanation:
Minimum 2 platforms are required to 
safely arrive and depart all trains.
 
Your Task:
You don't need to read input or print anything. Your task is to complete the function minimumPlatform2() which takes the arr, dep, days, platforms as inputs and returns a boolean value wheather it is possible to run all trains such that no train waits.
Constraints:
1 ≤ n ≤ 10^5
0 ≤ arr[i] ≤ dep[i] ≤ 2399
1 ≤ number_of_platforms < 100
1 ≤ days[i] < 100

Source: geeksforgeeks | Difficulty: MEDIUM

Starter code: #User function Template for python3



class Solution:    

    def minimumPlatform2(self, arr, dep, days, platforms):

        pass

    

Solutions:
from collections import defaultdict

class Solution:

	def minimumPlatform2(self, arr, dep, days, platforms):
		schedule = defaultdict(list)
		for (day, atime, dtime) in zip(days, arr, dep):
			schedule[day].extend(((atime, +1), (dtime, -1)))
		max_occupancy = float('-inf')
		for day_schedule in schedule.values():
			day_schedule.sort()
			current_occupancy = 0
			for (_, change) in day_schedule:
				current_occupancy += change
				max_occupancy = max(max_occupancy, current_occupancy)
		return max_occupancy <= platforms


class Solution:

	def minimumPlatform2(self, arr, dep, days, platforms):
		day_schedule = {}
		for i in range(len(days)):
			(arrival_time, departure_time) = (arr[i], dep[i])
			day = days[i]
			if day in day_schedule:
				day_schedule[day].append((arrival_time, departure_time))
			else:
				day_schedule[day] = [(arrival_time, departure_time)]
		for day in day_schedule:
			platform = [0 for i in range(2440)]
			requiredPlatform = 1
			for i in day_schedule[day]:
				platform[i[0]] += 1
				platform[i[1]] -= 1
			for i in range(1, 2401):
				platform[i] += platform[i - 1]
				if platform[i] > platforms:
					return False
		return True


class Solution:

	def minimumPlatform2(self, arr, dep, days, platforms):
		day_schedule = {}
		for i in range(len(days)):
			(arrival_time, departure_time) = (arr[i], dep[i])
			day = days[i]
			if day in day_schedule:
				day_schedule[day].append((arrival_time, departure_time))
			else:
				day_schedule[day] = [(arrival_time, departure_time)]
		for day in day_schedule:
			trains = day_schedule[day]
			trains.sort(key=lambda x: x[0])
			platform_schedule = []
			for train in trains:
				if len(platform_schedule) < platforms:
					platform_schedule.append(train[1])
				else:
					min_departure_time = min(platform_schedule)
					if train[0] >= min_departure_time:
						platform_schedule.remove(min_departure_time)
						platform_schedule.append(train[1])
					else:
						return False
		return True


import heapq

class Solution:

	def minimumPlatform2(self, arr, dep, days, platforms):
		day = {}
		for i in range(len(days)):
			(a, d) = (arr[i], dep[i])
			if days[i] in day:
				day[days[i]].append([a, d])
			else:
				day[days[i]] = [[a, d]]

		def check(cur_day, days, platforms):
			platf = []
			trains = days[cur_day]
			trains.sort(key=lambda x: x[0])
			for (a, d) in trains:
				if len(platf) < platforms:
					heapq.heappush(platf, d)
				elif platf[0] <= a:
					heapq.heappushpop(platf, d)
				else:
					return False
			return True
		for i in day:
			if not check(i, day, platforms):
				return False
		return True