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.
We have to give him that... His solution is unique there :D
Using count? It happens to loop for every element in set, through whole list. In case of multiples dictionary or counter should be used, and there is no other optimal way around, just to iterate over list once.
Another thing is, looking for square is generally longer then apply power if I am not mistaken, so this 'miserable' time difference might be covered by that.
By looking at memory complexity, and complexity in general, this solution isn't best practice at all, clever, maybe.
Yes and no. Even faster solution is with sets for general cases. dict is must have when you have duplicates. You can check my solution for example, maybe something may be improved, but for very large arrays (10^5+) it's a lot faster then this solution :)
Cool, however, not valid anymore :)
It seems like only O(n) solution there :|
This solution doesn't meet timelimit anymore.
https://imgur.com/1BskAXk
Image you can use.
Tests are invalid, generally I guess math solution is poorly implemented or description is lacking.
Example from description:
Layer 1 = X ;
Layer 2 = X | XX ;
Layer 3 = X | XX | XXX ;
Which obviously suggest 3 elements should return 2 - even example says that, but test is hardcoded for 3 elements there is just 1 completed layer, same story goes for 10 elements and 3 layers instead of 4.
EDIT: Okay, solved, but in my opinion, description just lacking in terms of visualizing 3d shape of tetrahedron, otherwise it's faulty/true example, depends how someone would read that, not anyone have to be native english and know what tetrahedron is, I believe that's the reason why visual example should be showed correctly.
EDIT2: Please give me 30 minutes I'll draw you 3d shape myself, and paste link in comment.
Cool, would be even better if that would work for every case, it seems like it won't work anymore against the tests, now tests covers this case, I've just checked because I was curious ^^
I figured it out on my own at second attempt...
Yea, circles and connectivity aren't a solution there, but I can't say more to avoid comment to be hidden.
If graph is connected isn't a solution, for example.
When you for example test {0:[1,2,3], 1:[0], 2:[0], 3:[0]}, this graph is connected, however you're able to split persons for two groups ([0] and [1,2,3] .
Graph don't have to be disconnected, to be True. I believe you failing this part, but I may assume wrong.
Comment has been hidden :/
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Loading more items...