Closed godkingjay closed 11 months ago
Hey I've got a Java solution, would you please assign this to me?
I just noticed a C++ and Java solution for the same already exists in the repo whose space complexity is O(n), but I have a got a different approach to it whose time complexity is O(n) and space is O(1), so shall I go ahead with that?
I just noticed a C++ and Java solution for the same already exists in the repo whose space complexity is O(n), but I have a got a different approach to it whose time complexity is O(n) and space is O(1), so shall I go ahead with that?
You can try doing it like this:
// Solution https://github.com/godkingjay/LeetCode/issues/1
class Solution {
/*
* Code for Solution https://github.com/godkingjay/LeetCode/issues/1
*/
}
// Solution https://github.com/godkingjay/LeetCode/issues/2
class Solution {
/*
* Code for Solution https://github.com/godkingjay/LeetCode/issues/2
*/
}
or like this:
LeetCode/
├── [DIFFICULTY]/
│ ├── [PROBLEM]/
│ │ ├── README
│ │ ├── solution.java
│ │ ├── solution.cpp
│ │ ├── [MY APPROACH]/
│ │ │ ├── README
│ │ │ ├── solution.java
│ │ │ └── ...
│ │ └── ...
Difficulty
Medium
Problem Description
Given a signed 32-bit integer
x
, returnx
with its digits reversed. If reversingx
causes the value to go outside the signed 32-bit integer range[-231, 231 - 1]
, then return0
.Assume the environment does not allow you to store 64-bit integers (signed or unsigned).
Example 1:
Example 2:
Example 3:
Constraints:
-231 <= x <= 231 - 1
Link
https://leetcode.com/problems/reverse-integer/