Skip to content

Commit

Permalink
Solve: ReverseInteger
Browse files Browse the repository at this point in the history
  • Loading branch information
fkdl0048 committed Sep 27, 2024
1 parent a3c22f1 commit 9f9d5f7
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
8 changes: 8 additions & 0 deletions 2024/C++/DataSturct.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <bits/stdc++.h>

using namespace std;

int main()
{

}
Binary file added 2024/C++/DataSturct.exe
Binary file not shown.
17 changes: 17 additions & 0 deletions 2024/LeetCode/7. ReverseInteger.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class Solution {
public:
int reverse(int x) {
int ans = 0;
while (x != 0){
int digit = x % 10;

if ((ans > INT_MAX / 10) || (ans < INT_MIN / 10))
return 0;

ans = ans * 10 + digit;
x = x / 10;
}

return ans;
}
};

0 comments on commit 9f9d5f7

Please sign in to comment.