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 Children 2
Angry Children 2
Sort by
recency
|
77 Discussions
|
Please Login in order to post a comment
O(n* log(n)), the actual algo takes O(n) time, but it requires packets to be sorted, which takes n*log(n)
Top Notch Training services to help you and your furry friend build a stronger bond right here! Our Trainer is a recent graduate of a top dog training school and has a passion for working with dogs of all breeds and sizes. At The Regal Beagle, we understand that every dog is unique and has different needs. That's why we offer personalized training programs that are tailored to your dogs specific needs. If you're looking for a dog trainer who is passionate about what he does and decdicated to helping you and your dog succeed, look no further that The Regal Beagle. Contact us today to schedule a consultation and learn more about our services.
Here is my solution in java, javascript, python, C, C++, Csharp HackerRank Angry Children 2 Problem Solution
I'm not sure why this is rated as hard. A moment of thought shows that obviously you want to choose k numbers that are as close as possible, leading to an obvious O(nlogn + nk) solution, and then once you've written that it's trivial to see how to re-group the math you've written to eliminate the factor of k so that the largest few test cases don't time out.
Here is the solution of Angry Children 2 Click Here