Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save TechWithTy/105adc5549c6fdf4e870c1e022c1f13e to your computer and use it in GitHub Desktop.
Save TechWithTy/105adc5549c6fdf4e870c1e022c1f13e to your computer and use it in GitHub Desktop.
7. Reverse Integer
/**
* @param {number} x
* @return {number}
*/
var reverse = (x) => {
if (x < 0) {
return -1 * reverse(-x)
}
const solution = (x + "").split('').reverse().join('');
return (solution > 2 ** 31 - 1) ? 0 : solution;
};
@TechWithTy
Copy link
Author

made public

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment