Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
sure, but as a beginner, I'll focus on the more readable ones first :D
Would be nice if constraints were in the description.
You're asking programmers to not explain why bad code is bad.
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).
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.
What's really crazy is that this fever dream predates ChatGPT homie really handcrafted this
the input is an
unsigned
(32-bit) so it logically cannot be negative; the output is anunsigned long long
(64-bit). the tests do show you the input, expected and actual values. your code does not take care of avoiding integer overflow.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.
While concise, this solution should not be considered best practices given its time complexity of O(n^2)
each of the input arrays are always of equal length. iterating through each array individually is not necessary.
Sisyphus
One of the solutions of all time
Got it. Thank you!
No, that's not it, use this:
puts "<" + pin + ">"
to print the input.This comment is hidden because it contains spoiler information about the solution
Loading more items...