SCC0103 - Editorial

PROBLEM LINK:

Practice

Contest

Author: Learner Club

DIFFICULTY:

EASY

PREREQUISITES:

Sorting, Hashing

PROBLEM:

In short, problem was to find the maximum number of guests who can arrive at the same time.

EXPLANATION:

Method 1 O(n*log(n)) Sort the arrival times using any n*log(n) sorting algorithm then find most frequent one just by traversing list in O(n) time. To sort arrival time you can use pair in utility and sort function in algorithm of C++ STL or you can also use c qsort function with appropriate compare function or you can also convert time in minutes and sort normally.

Method 2
O(n)

Convert all arrival times in minutes so all arrival times will be b/w 0 to1440. You can hash all arrival times to an array of size 1440 to store frequency of them in array and keep track of maximum frequency. You can also use a 2D array of [24][60] to hash without converting time into minutes and do the same.