• Post Reply Bookmark Topic Watch Topic
  • New Topic

Reversing an integer  RSS feed

 
Ahsan Bagwan
Ranch Hand
Posts: 254
1
Java MySQL Database Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm solving this problem from leetcode. I am handling the sign by adding string to the start of the string. But after running this problem online the test case failed. Could someone point out what corner case I am not handling here?

 
Karthik Shiraly
Bartender
Posts: 1210
25
Android C++ Java Linux PHP Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do they restrict inputs only to decimal integers?

Also, what output does it expect? That the number is printed on console?
 
Liutauras Vilda
Marshal
Posts: 4800
330
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your subject says "Reversing an integer". At the moment you're reversing String. Maybe this is a problem.
Try to print out numbers in reverse way by using modulus operator.
 
Ahsan Bagwan
Ranch Hand
Posts: 254
1
Java MySQL Database Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Reversing the string converted from integer might be the problem. Thanks.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!