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.
Angry Professor
Angry Professor
Sort by
recency
|
1958 Discussions
|
Please Login in order to post a comment
C#
return a.FindAll(x => x <= 0).Count >= k ? "NO" : "YES";
Here are my c++ solutions for this problem, you can watch the explanation here : https://youtu.be/MKqtPYhaNrs Solution 1 O(N)
Solution 2 O(nLog(n)) because of the sorting, it's not the best option here, but it's still interesting to know because it can be useful in case you received a sorted array in a similar problem.
There is a confusing typo in the instructions. The 2 lines below conflict:
"The first 3 students arrived on. The last 2 were late. The threshold is 3 students, so class will go on. Return YES."
"It must return YES if class is cancelled, or NO otherwise."
The first instruction makes it seem that you should return YES if the class is held, the second says the opposite. From the sample case you can tell that the 2nd version is correct, but it's confusing.
** Python Solution **
def angryProfessor(k, a):
java 8