+ 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

25th Jul 2022, 12:10 PM
Akash Gupta
Akash Gupta - avatar
2 ответов
+ 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
25th Jul 2022, 12:32 PM
Jayakrishna 🇮🇳
0
str(x)[::-1]
25th Jul 2022, 1:27 PM
Anton
Anton - avatar