+ 1
Question is for reverse the number.
Hello everyone question is simple when we have positive integer but as you can see in 2nd example How we can solve that. Example 1: Input: x = 123 Output: 321 Example 2: Input: x = -123 Output: -321
2 Respostas
+ 3
if( x < 0 )
x = -x;
Do reverse, add minus.. Or display -reverse.
edit:
Akash Gupta
in fact found that there is no need to check for negetives, if you use this logic..
it's same as per positives..
here is @ipang solution..
https://code.sololearn.com/cNLi6Xs9Wlu9/?ref=app
0
str(x)[::-1]