Skip to content

Commit

Permalink
Merge pull request neetcode-gh#955 from FahadulShadhin/c-solutions
Browse files Browse the repository at this point in the history
Adding 7-Reverse-Integer.c
  • Loading branch information
Ahmad-A0 authored Aug 29, 2022
2 parents a624a4a + ee48aa0 commit 1e5af54
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions c/7-Reverse-Integer.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
int reverse(int x) {
long reversed_num = 0;
while (x != 0) {
reversed_num = reversed_num * 10 + x % 10;
x /= 10;
}

if (reversed_num < INT_MIN || reversed_num > INT_MAX)
return 0;

return reversed_num;
}

0 comments on commit 1e5af54

Please sign in to comment.