do you mean something different from the worst case or what?
Yeah, I messed it up. I calculated the repeated string concatenation as T(n) = n^2 as in the worst case, but comparisons as T(n) = 1 as in "more realistic" scenario (i.e. you're unlikely to deal with GigaByte-sized strings, and the constant factor is so low, the O(n) comparsion can be negligible). This particular solution is indeed O(n^3)
What is n?
In the worst scenario all the inputs' sizes are inifinitely big, so both the string and the list will be n, no?
Sorry, it is a suggestion, not an issue... Nevertheless I added it.
Please verify and stop with suggestions:-) CW is so slow that it takes times to re-publish and most often it times out when re-publishing.
I did not look up the implementation of 'all' in cpython, but my tests show that all seems to end when one 'False' is found.
So no, i think this is pretty efficient, as he is passing an iterator not a list to all.
EDIT: Buildin all indeed breaks if it encounters a false, see: 1
I think this is a tough kyu 5 ;)
to be honest, this should've been 8kyu
Ranks cannot be changed, but I totally agree, it's a bit too easy for a 6 kyu. A small bit of math would do the trick well.
Yeah, I messed it up. I calculated the repeated string concatenation as
T(n) = n^2
as in the worst case, but comparisons asT(n) = 1
as in "more realistic" scenario (i.e. you're unlikely to deal with GigaByte-sized strings, and the constant factor is so low, theO(n)
comparsion can be negligible). This particular solution is indeedO(n^3)
In the worst scenario all the inputs' sizes are inifinitely big, so both the string and the list will be
n
, no?With hashing a newly created string - yes.
Looks correct to me for the worst case.
Only if the hashes are already calculated and cached; otherwise
len(l[i])
has to be somewhere as well.What is
n
? And do you mean something different from the worst case or what? Arbitrary strings can't be compared in O(1).That's not how
O
works, and your reasoning is wrong too. This solution isO(n^2)
, and there's no asymptotically better algorithm for this task.This comment is hidden because it contains spoiler information about the solution
I did but this expression has many interpretations and I wanted to know yours.
Thanks for your kindness.
I don't understand... Say it in English:-)
Sorry, it is a suggestion, not an issue... Nevertheless I added it.
Please verify and stop with suggestions:-) CW is so slow that it takes times to re-publish and most often it times out when re-publishing.
Added though without any interest since everybody already knows the answer:-)
I find 5 kyu about right. Oh, and thanks for the compliment!
I did not look up the implementation of 'all' in cpython, but my tests show that all seems to end when one 'False' is found.
So no, i think this is pretty efficient, as he is passing an iterator not a list to all.
EDIT: Buildin all indeed breaks if it encounters a false, see: 1