I don’t understand why the GeeksForGeeks solution to this exact problem doesn’t work, would love if someone could explain it.
// Handling negative numbers
(num < 0)
num = -num ;
prev_rev_num = 0, rev_num = 0;
(num != 0)
curr_digit = num%10;
rev_num = (rev_num*10) + curr_digit;
// checking if the reverse overflowed or not.
// The values of (rev_num - curr_digit)/10 and
// prev_rev_num must be same if there was no
((rev_num - curr_digit)/10 != prev_rev_num)
prev_rev_num = rev_num;
num = num/10;
)? -rev_num : rev_num;