This is a good implementation of the recursive approach. Which is the first thing that comes to mind when interviewing. The problem with this solution, is time complexity which is O(2^n) where n is the length of s. A better approach is to use Dynamic programming. Then the time and space complexity become O(p1p2) where p1 is the length of part1 and p2 the length of p2.

That is an interesting question.
I could have converted them first to numbers but it is not needed.
JavaScript string comparison is alphabetical. Alphabeticaly '11' is less than '12'. That is how it works.

This is a good implementation of the recursive approach. Which is the first thing that comes to mind when interviewing. The problem with this solution, is time complexity which is O(2^n) where n is the length of s. A better approach is to use Dynamic programming. Then the time and space complexity become O(p1p2) where p1 is the length of part1 and p2 the length of p2.

Make some simple expamples like [4,2,1,3] test it with 'R' an with 'L', try to see if you notice a pattern

What do you mean specifically?

That is an interesting question.

I could have converted them first to numbers but it is not needed.

JavaScript string comparison is alphabetical. Alphabeticaly '11' is less than '12'. That is how it works.

how does this work for you ?, i mean how can you check if one parameter bigger than the other while both are strings!!! ?

!

Here is some advice how to approach this. Solve some examples on paper first. Notice what happens. Then coding the solution is easy.

!

!

This comment is hidden because it contains spoiler information about the solution

I really wanted to use Array.from() in my solution, but couldn't make it work. Only got this far:

const between2 = (num1, num2) => {

return Array.from({ length: num2 }, (_, i) => i + 1)

}

Could you please explain how yours works so I can understand it? MDN only has a simple example of it.

!

Nice kata! I saw some really clever solutions and some good practices. Thanks.

!

!

## Loading more items...