Algorithms Flashcards ionicons-v5-c

Given a 32-bit signed integer, reverse digits of an integer.Example 1:Input: 123Output: 321Example 2:Input: -123Output: -321Example 3:Input: 120Output: 21

var reverse = function(x) { const reversed = parseInt(Math.abs(x).toString().split('').reverse().join('')) * Math.sign(x); return (reversed <= 0x7fffffff && reversed >= -0x80000000) ? reversed : 0;};