Ad
  • Custom User Avatar

    Readable and ideomatic.
    Not performant for large arrays. But that was not required in the description.
    So "best practice" from me

  • Custom User Avatar

    Great. Performs for big arrays. And readybility is good too, whenever I prefer a variable like 'offset' for 'i+1'.

  • Custom User Avatar

    Contrary to other comments, I like this soluluton. Of course it doesn't perform on large arrays. But there is no "large array warning" in the description. And the code is clear, readable and ideomatic. So for me the high score on 'best practices' is deserved.

  • Custom User Avatar

    I struggled with the same problem with the spaces and like your workaround. Clever.

    The more common and probably better solution is to use split(' ') instead of split().
    Takes care of the spaces and works even if the word distances are not consistent.

  • Custom User Avatar

    Algorithm is efficient because it stops early. Code is good to read despite the extra lines for the early stop. I like it.