Ad
  • Custom User Avatar

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

  • Default User Avatar

    Stevele like your solution man, keep it up.

  • Custom User Avatar

    markus.benko, that is a crazy smart solution you have. Here I was feeling happy about my use of a hashmap.

  • Default User Avatar

    I also don't know why but it seems to happen quite often that solutions are considered best practice which clearly shows that the idea of Green Computing hasn't reached most software developers. Too bad that we can't downvote, beginners really shouldn't learn from solutions like this one. And believe it or not, my solution is about 100 times as fast as this one for both strings = "abc...xyz" and it doesn't even create intermediate objects or arrays most of the time. ;-) What I have to admit is that I have forgotten to shortcut cases where str2 is longer than str1.

  • Default User Avatar

    Agree. Relative performance can be measured objectively, so I think it should be measured by codewars itself for each propossed solution and shown there.

  • Default User Avatar

    Agreed. This solution is indeed clean and nicely organized. However if performance is to be considered, this solution is not as good as others are.

  • Custom User Avatar

    Why is an O(n^2) solution voted to Best Practices (and Clever?!) for a Kata with "Performance" and "Optimization" tags? The description even says

    Performance needs to be considered

    My solution (and others that haven't been voted to the top) are O(n) and arguably more clever than this brute-force method.

  • Default User Avatar

    This program runs in O(N*M) since
    str1.contains(s) is O(N) with N = length(str1), M = length(str2)

    Using List it takes O(N) only, N = max length of (str1, str2).

  • Default User Avatar

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