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.
Same here my solution stops when it finds a change whereas in python the "best" answer iterates 4 times over the whole array.
BUT if performance does not matter than lets iterate 4 times over it if performance matters optimize the code.
I cannot say what is actualy wrong in the code but i know which test fails:
console.log("Result from my solution is "+iqTest("1 1 2")); --> should be 3 but is 2
console.log("Result from my solution is "+iqTest("1 2 2")); --> should be 1 and is 1
console.log("Result from my solution is "+iqTest("1 2 1")); --> should be 2 but is 1
I think your code just checks for a change but does not take into account the next step
alphabeticaly == alphanumerical sorting which uses the first char to sort any thing so a string starting with 1 is allways befor 2...
1
123
12345
2
234
3
...
it is sorted alpha numerical so a string starting with '1' is allways before a string starting with '9'
1
12345
2
2345
...
..
9