Skip to content

Instantly share code, notes, and snippets.

@Silva97
Created June 23, 2019 00:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Silva97/36d5c3fd301c093f965361d22813e924 to your computer and use it in GitHub Desktop.
Save Silva97/36d5c3fd301c093f965361d22813e924 to your computer and use it in GitHub Desktop.
/*********************
* Resolução do problema: https://leetcode.com/problems/reverse-integer/
*********************/
int aux_rev(int x, long long int rev)
{
if(rev > INT_MAX || rev < INT_MIN) return 0;
if(!x) return rev;
return aux_rev(x/10, rev*10 + x%10);
}
int reverse(int x)
{
return aux_rev(x, 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment