c++ - Palindrome without using extra space -
i know various ways check if integer palindrome or not using string conversion, stack , number breaking, here question "how can check wether integer palindrome or not, without using any extra space?"
you can revert number code like:
int revert(int num) { int reverted = 0; while (num) { reverted = reverted*10 + num%10; num /= 10; } return reverted; } and check if
num == revert(num)
that all. sorry giving exact solution instead of tip, don't think have given tip without solution itself.
Comments
Post a Comment