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.
too complex
Small nitpick, but I believe space complexity is still O(1) in practice. It will depend on the number of unique characters, not the total count. The number should remain relatively low (<256 for ASCII), although it can technically be as high as
n
for variable-length encodings (e.g., UTF-8).I give points for "clever" use of acollections.
But not best practice. Python has better solutions that are more concise. Not a fan of using 2 for loops here. My time trials show that a translation table is better, but also you are correct that using a dict is better than count.
Nice solution 👏👏👏
Brilliant
Allocation for new string is expensive.
This comment is hidden because it contains spoiler information about the solution
Very informative solution!
That doesn't make the complexity exponential, that would just make it O(n + n), which is still just O(n). O(n^2) would be if there was a loop that went through n and a nested loop that always went through n, or something similar. Maybe you mean that .join would be faster than +=.
TIL, thanks.
Is there a way to use defaultdict as dict comprehension?
You can round expression $p0 = $p0 + ($p0 * ($percent / 100.0) + $aug); to $p0 += ($p0 * ($percent / 100) + $aug);
This comment is hidden because it contains spoiler information about the solution
@nUG48YpaiHBG you mean in terms of performace?
@felyxjet thank you for this comment, I knew strings were immutable but didn't put together that it meant creating a new string every time.
Does this mean that using the str.join() method is like using the list.append() method?
TIA!
The version you suggest will be slower (because that thing is implemented in pure python, while the present one is done with cython). But yes, the present use isn't mandatory.
Loading more items...