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.
Good solution, at the cost of memory. It's always a time/memory tradeoff.
The thing with the index trick is that you don't find them in an array - you find them in the object you create at the key of (lettersinanagramsorted).. so your total O() for the algo is A:(Time to Create and populate the index) + B:(time to sort and find one word in the index). For A:, you have to re-sort the letter in the word (of size k), (n) times - so that == n x sortletters(k) == n x klogk [assuming k is sorted using MergeSort, which I think V8 does and the avg. time of MergeSort.]. B: == (not sure exactly, but pretty sure it's less than k) == k .: O() == nklogk + k, so it should be better than n^2. If you can pre-populate the index, you can cut it down to just k. This is a good Kata to know, because you will get this one in phone interviews sometimes... (I got this exact question pretty much on the last phone screen I did.)
Awesome kata - I think if you use the index trick a lot of people used, you get it faster than that.