Ad
  • Custom User Avatar

    What would be the optimal solution?

  • Custom User Avatar

    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)

  • Custom User Avatar

    please can you explain more about this? and what would be the most performant solution in your opinion ?

  • Custom User Avatar

    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.

  • Default User Avatar

    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.

  • Default User Avatar

    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.