Website: https://leetcode.com/problems/reverse-integer/
Test instructions
Reverses the number, plus or minus.
Analysis:
The idea is obvious,
The emphasis is on some tricky input and output.
Solution:
Because of ignoring the positive and negative, but also use the MoD.
Naturally think of ABS ...
However, ABS is not fully applicable for int.
Before use, judge whether int_min or Integer.min_value
I do not want to remember this positive or negative, with X/abs (x) to solve ...
Then you need to consider that 0/0 is a violation of mathematical laws.
This also needs to be taken out separately.
Then the cross-border situation is naturally to be considered, belongs to the conventional.
Code:
Https://github.com/LiLane/leetcode/blob/master/java/007-ReverseInteger-201504291907.java
Https://github.com/LiLane/leetcode/blob/master/c%2B%2B/007-ReverseInteger-201504291908.cpp
[Leetcode]-007-reverse Integer