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
|
1982 Discussions
|
Please Login in order to post a comment
The description says: "The first 3 students arrived on. The last 2 were late. The threshold is 3 students, so class will go on. Return YES." So yes when the class is will hold.
But the solution requires the oppsite, so yes when cancelled.
Here is problem solution in Python, Java, C++, C and Javascript - https://programmingoneonone.com/hackerrank-angry-professor-problem-solution.html
Why this is wrong answer althrough the algo is same.
string angryProfessor(int k, vector a) { // int attendees = 0; // for(int el: a) if(el <= 0) attendees++; // return attendees >= k ? "NO":"YES"; int atee = 0; for(int i = 0; i < a.size(); i++){ if(a[i] <= 0){ atee += 1;
}
Why this is wrong answer althrough the algo is same.
string angryProfessor(int k, vector a) { // int attendees = 0; // for(int el: a) if(el <= 0) attendees++; // return attendees >= k ? "NO":"YES"; int atee = 0; for(int i = 0; i < a.size(); i++){ if(a[i] <= 0){ atee += 1;
}
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.