--if the question constraints is 10^18 and input is given in digit then never use stoi,atoi,or any kind of string into digit number because it gives always tle.
--Never Use stoi,atoi with to_string it also give tle .I wasted 1 hr to solve this problem.......so don't do that...and
Happy journey to _____ to master.
No. The function
atoi
itself will work fast. However, instead of the 64-bit number $$$n$$$ it will return some 32-bit number which won't be equal to the correct result if $$$n$$$ is far enough from $$$0$$$. Most of compilers will return $$$n$$$'s 32 trailing bits: https://godbolt.org/z/47eox791n. I guess it's non-standard, it is just how it is implemented.However, I was able to find a compiler which instead returned
std::numeric_limits<int32_t>::max()
, it is also demonstrated in Godbolt.