Memory Related problem in Project Euler Problem no- 35

Hello Everybody recently I solved Project Euler [problem=35][1]

My code is [here][2] …

I don’t know what kind of stderr it is showing.

I think this error is due to using a vector of 1000000 size …

My code is correct and there is no logical error its giving me right answer.
But i think there is some memory related problem.

Can anybody explain me this error and solution.

Thanks in advance

Happy Coding!!!
[1]: http://projecteuler.net/problem=35
[2]: http://ideone.com/M0q5XH

No. It is fine to take a vector of that size. The problem is you din’t declare the size of the vector initially, and then you are assigning some element to some value. http://ideone.com/gArQ6r is the correct version of your code.

OR, you can push_back elements instead of just assigning.

1 Like

thanks @bugkiller

No problem buddy :slight_smile: