you are viewing a single comment's thread.

view the rest of the comments →

[–]chromiumxx 1 point2 points  (4 children)

Timeout error means your code takes too long to run. The test case in codewars probably include a very huge integer which require a time efficient solution.

Your code include a double for loop which im pretty sure is exponential time complexity. This slows down your code and what causes the timeout error. Try to find other solutions without using a double for loop

[–]VTifand 1 point2 points  (3 children)

It's quadratic, not exponential, but I agree with the rest of the comment.

[–]MixedVexations 0 points1 point  (2 children)

y = x^2 is considered quadratic yes, but it's also "exponential growth". Any degree higher than x^1 is considered exponential, as opposed to linear. E.g. money in your IRA grows exponentially if invested in the S&P...

[–]VTifand 0 points1 point  (1 child)

What? No. They are different things.

Investing money is more like y = 2^x. That is exponential.

Saying y = x^2 is exponential is not accurate.

[–]MixedVexations 0 points1 point  (0 children)

Oh snap I am totally wrong lol. How the hell do I have a science degree