Ad
  • Default User Avatar

    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.

  • Default User Avatar

    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

  • Default User Avatar

    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
    ...

  • Default User Avatar

    it is sorted alpha numerical so a string starting with '1' is allways before a string starting with '9'
    1
    12345
    2
    2345
    ...
    ..
    9