Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
isnt sort supposed to be time consuming? instead of just a single pass you are doing an nlogn operation just for sorting
this makes the most sense.
That's sexy.
Really clever!
All? short circuts.
You should stop once you witness failure of monotonicity, e.g. don't traverse the whole array if heights[0] > heights[1]. That way your average complexity will be even better than linear.
Comparing an array like that would be n, linear.
Absolutely, you don't happen to know the Big O time for comparing do you?
So obvious once I saw it; but didn't cross my mind when I was trying to solve it. Nice one!
Haha yeah, ruby has a lot of hidden gems(tee hee) in the collections docs
Nice. Your solution uses methods I wasn't familiar with (total beginner)
Sorting isn't really needed, you can do it a lot faster comparing every two elements.