Sum root to leaf numbers stoi error

question - https://www.interviewbit.com/problems/sum-root-to-leaf-numbers/
my code - https://ide.geeksforgeeks.org/NRWNopeYHn
error on interviewbit platform-
run time error
terminate called after throwing an instance of ‘std::out_of_range’
what(): stoi
Aborted

stoi function won’t work for large strings because this will exceed the range of integer itself. Try converting the string to integer yourself while taking mod 1003 at each step so that it never exceeds the range.

https://ide.codingblocks.com/s/43831

Here is my code for your reference.

1 Like