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.
Beautiful!
Yes! Copy the array first (e.g.,
Array.prototype.slice
or[...array]
), then you can mutate it as much as you want.I knew there would be a solution with some bit hacking :)
As a more focused hint, look up the most common data structures implemented in your language of choice. A few of them can help you.
No worries, samiamahwash! Sorry to have assumed this. As eptaceps mentioned, look for "algorithm complexity". In short, some algorithms are faster than others to accomplish the same task. We usually use this big-O notation to describe how a certain algorithm scales with its input. O(N^2) mean that the calculations done by the algorithm scale with the square of its input size (or whichever other property natural to the problem). This is worse than a O(N) algorithm, which does a lot less work and hence is notably faster for large inputs.
This comment is hidden because it contains spoiler information about the solution
O(N) works fine without timing-out. By
N
I mean the sum of list sizes passed as argument.Besides solving the problem, the solution must be optimized enough to be able to handle the lists in the testcases (close to 10k in size each) Check the time complexity of your solution and think of ways to reduce it (e.g., from O(N^2) to O(N)).
Hi! It is a special syntax in Elixir to pattern match a list.
Example:
Usually, using functional programming jargon, leader is called head and rest is called tail.
You are absolutely right. Don't know what I was thinking hahaha
This comment is hidden because it contains spoiler information about the solution
There is no need to do it. If an empty list is passed as argument to the map function it will just return a new empty list (or map object in python 3+).
Hahahaha nice!
You are welcome. Happy coding :)
This comment is hidden because it contains spoiler information about the solution
Loading more items...