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.
This comment is hidden because it contains spoiler information about the solution
This has O(n^2) time complexity
You probably don't need the answer as of now. You might not even see this comment. But to anyone who is interested in the explanation, here it is:
Storing an object as a key inside of an another object doesn't really work. Object keys in javascript are type of String (Even when you access a property of an object using a number i.e. obj[1] javacsript internally converts it to a String type). And since keys in an object should be of type string any object that is used as a key inside of another object will be turned into "[object Object]". That's why the check on line 4 fails to distinguish the other objects. The solution should work with maps though. Unlike in objects, you can use objects as keys in maps. For additional info on maps: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map
Acording to my peformance tests the one with sum and map is most time efficient, i was not expecting it to be so comparing to pure loops, but i guess we are better off using built-in functions?
PS: i had solved it like this as well...
This comment is hidden because it contains spoiler information about the solution
How would you put squares [14, 9, 1, 1, 1] together to form a rectangle?