Solution in ruby is here for this problem


#1

class Solution
# @param a : integer
# @return an integer
def reverse(a)
=begin rev = 0
while a!=0
rem = a%10
rev = rev*10 + rem
a/=10
end
return rev

=end
neg = a < 0
a = a.to_s.reverse.to_i

return  0 if (a > 2147483646 || a < -2147483647)

return neg ? -a : a
end

end