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?
i) your code doesnt run
ii) checking for divisors up to candidate^0.5 is sufficient do determine if it's a prime
iii) why print your result? return it!
iv) you don't have any testcases
v) happy coding
7 kyu that's timing out isn't really 7 kyu is it?
This comment is hidden because it contains spoiler information about the solution
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'm enlightened. Thank you very much.
didn't know they had python back then!
This is too easy for 6 kyu
This comment is hidden because it contains spoiler information about the solution
i) your code doesnt run
ii) checking for divisors up to candidate^0.5 is sufficient do determine if it's a prime
iii) why print your result? return it!
iv) you don't have any testcases
v) happy coding
I did but this expression has many interpretations and I wanted to know yours.
Thanks for your kindness.
http://giyf.com
I don't understand... Say it in English:-)
Loading more items...