Sequence of questions:
Recommended Blogs:
Number and place topic categories:
Bit manipulation of numbers:
invert an integer
- stack structure
- Convert it to a string, and flip it according to the string method.
- Gets the trailing digit of this integer using modulo arithmetic. Take 12345 as an example, first get 5, then get 4, then 3, 2, 1, we can reversely stitch a number in this order, and achieve the reverse effect.
The first and second methods are not as computationally efficient as the third.