We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I appreciate your thinking on this problem but your time complexity would 0(nlogn) if we sort it and then check the starting elements until they are greater than 0. This doesn't matter for small inputs but it really does when the input grows too large.So the best approach would be read the array and count the number of students who are on time i.e whose arrival times<=0 and return based on the K(max threshold) value.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Angry Professor
You are viewing a single comment's thread. Return to all comments →
I appreciate your thinking on this problem but your time complexity would 0(nlogn) if we sort it and then check the starting elements until they are greater than 0. This doesn't matter for small inputs but it really does when the input grows too large.So the best approach would be read the array and count the number of students who are on time i.e whose arrival times<=0 and return based on the K(max threshold) value.