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.
What would be the optimal solution?
I believe that by using includes, the code will have to check the entirety of b array for each the value of array a, resulting in time complexity of O(n * m)
please can you explain more about this? and what would be the most performant solution in your opinion ?
If you have ever written an algorithm that solves the towers of hanoi, you can fairly easily come up with the oneliner formula.
Granted, if you have never written a solver for the towers of hanoi before, this task becomes harder, as you now also have to solve the game, rather than merely determining the number of steps your solver takes.
Short and clear, but pretty bad performance.
This will have to scan all of b for each element in a.
I'm baffled by how often in this site the "top" solution is just the shortest one, as if number of lines is the ultimate measure of good practice.
I'm seeing a lot of people suggesting this kata is too easy to be 6-kyu.
I suggest to those people to solve this with your own algorithm, without using the known 1-line formula.