You are viewing a single comment's thread. Return to all comments →
But if you solve without sorting, you dont even need to take in the whole input... and end up solving in O(n) time.
(java 8 solution)
k: the threshold number of students
a: an array of integers representing arrival times
static String angryProfessor(int k, int[] a) { for (int i = 0; i < a.length; i++) { if (a[i] <= 0) { k--; } if (k == 0) { return "NO"; } } return "YES"; }
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 →
But if you solve without sorting, you dont even need to take in the whole input... and end up solving in O(n) time.
(java 8 solution)
k: the threshold number of students
a: an array of integers representing arrival times