Welcome to LeetCode Discuss.  Please read the FAQ to help yourself making the best use of Discuss.
Ask a Question
Back to Problem

Welcome to LeetCode Discuss.

This is a place to ask questions related to only OJ problems.

Please read the FAQ to help yourself making the best use of Discuss.

How do we handle the overflow case?

+2 votes
197 views

Throw an exception? Good, but what if throwing an exception is not an option? You would then have to re-design the function (ie, add an extra parameter).

asked Oct 29 in Reverse Integer by caidiexunmeng (140 points)

1 Answer

–6 votes

As a cpp coder, I will use the long long to handle the overflow case. Since all input number is in int range, there is no way to overflow the long long.

answered Oct 29 by Shangrila (4,330 points)

...