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
|
1977 Discussions
|
Please Login in order to post a comment
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.
Problem wording is confusing, seems misleading
Perl:
Ruby:
a.reduce(0) do |sum,num| sum += 1 if num <= 0 sum end < k ? 'YES' : 'NO'