Ad
  • Custom User Avatar

    Would be nice if constraints were in the description.

  • Custom User Avatar

    You're asking programmers to not explain why bad code is bad.

  • Custom User Avatar

    While the difference is negligible in this case, constant time or O(1) is not inherently faster than linear time O(n) where n is relatively small (n <= 40). Because we are counting letters and single digits, that gives us 36 possible values that must be counted (26 letters + 10 digits).

    In this case, it would actually make more sense to store the count of each value in an array of pre-defined length.

    I'm aware this is a trivial distinction in this case, but I think there's value in educating others that O(1) is not ALWAYS better than O(n).

  • Custom User Avatar

    I don't think there's much of a difference, at least performance wise, to calling lower() on the whole string or each individual character. Strings are, in actuality, just character arrays. By calling lower() on the whole string, the function must still be applied to each individual character.

  • Custom User Avatar

    What's really crazy is that this fever dream predates ChatGPT homie really handcrafted this

  • Custom User Avatar

    I am having problems with this kata in C language.

    Example- My test will fail with the following message:

    "for n = 2494392752, expected 4168116981449254, but got 0"

    Despite showing n as a positive integer, this is seemingly not the case as I get a different, non-zero output when changing n to the absolute value of n. This would only make sense if n was somehow negative.

    Additionally, for cases such as this, nothing is printing to the console, allowing me to debug the issue. There are no errors, and I have tried printing both the unsigned long n (unmutated from the function argument) as well as its necessary cast to int.

  • Custom User Avatar

    While concise, this solution should not be considered best practices given its time complexity of O(n^2)

  • Custom User Avatar

    each of the input arrays are always of equal length. iterating through each array individually is not necessary.

  • Custom User Avatar

    One of the solutions of all time

  • Custom User Avatar

    Got it. Thank you!

  • Custom User Avatar

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

  • Custom User Avatar

    yea, that was a hold-over from an alternative filter i had copied and pasted from. Didn't catch it when refactoring. Thanks for the tip though.

  • Custom User Avatar

    It's long and it's dirty. But dangit I'm still proud!