Ad
  • Custom User Avatar

    Using a dictionary would be slower than using a simple int array as OP has done. You're adding more overhead/complexity and probably memory usage as well by using a dictionary.

    OP's solution is exceedingly fast (see my comment about his error, though). Even much faster than my own (using a short str1 input...really long ones, my code is much faster), which is faster than all of the other solutions posted here that I've tested.

  • Custom User Avatar

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

  • Custom User Avatar

    Per kata author's instructions, only lower case letters will be provided. Which means zero non-letters, whitespace, digits, null/empty strings.

  • Custom User Avatar

    I'm nitpicking, but starting for loop from 2 would be give the same output.

  • Custom User Avatar

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

  • Custom User Avatar

    +1 Efficiency, only concern is if str2 is empty string then it reports canScramble true, but that's just me being difficult :P