Ad
  • Custom User Avatar

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

  • Default User Avatar

    The instructions stated that the strings only contain characters from a-z and you are checking that this is true. I do not think that that was intended. I figured they stated that so we don't get caught up in the question of international alphabets and how to count the character counts in them. But I may be wrong...

  • Default User Avatar

    I like the use of Func, makes the whole thing really concise. The only thing I don't like about this, is that you iterate through each array twice, where once would suffice.

    I am trying to come up with a way to do that using "getMinMaxLength Func<string[], Tuple<int, int>>", where you find the min and max in one iteration. I am not yet familiar enough with lambdas in C# to get it right without thinking longer about it. Do you know how?

  • Default User Avatar

    My solution is kind of similar, but instead of returning an int array, I use out parameters for the minLength and maxLength. I think this makes it clearer for any potential user of the function that there will only be two values returned. Also, you then don't need to rely on your convention that i1[0] is the Min and i2[1] is the Max.

  • Default User Avatar

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

  • Default User Avatar

    I like that it is nice and clean and instantly understandable. However, this computes every possible combination of (x,y). That is really inefficient and lets the number of operations increase quadratically.

    Let's assume a1 and a2 are of the same length. If they have 10 elements each, that is 100 times the inner loop is executed. If they have 100 elements, that is already 10k times the inner loop is executed!

    We really don't know the context of this code which is always important to ensure we don't spend time optimizing code that is seldomly executed or with such input that any potential improvements would not be worth it.