LeetCode
class Solution {
public int reverse(int x) {
int y;
int _x = 0;
while (x != 0) {
y = x % 10;
if (_x > Integer.MAX_VALUE / 10 || _x < Integer.MIN_VALUE / 10)
return 0;
_x = _x * 10 + y;
x /= 10;
}
return _x;
}
}
class Solution {
public int[] twoSum(int[] nums, int target) {
int[] result = new int[2];
for (int i = 0; i < nums.length; i++) {
for (int j = 0; j < nums.length; j++) {
if (i != j && nums[i] + nums[j] == target) {
result[0] = i;
result[1] = j;
return result;
}
}
}
return result;
}
}
class Solution {
public int reverse(int x) {
int y;
int _x = 0;
while (x != 0) {
y = x % 10;
if (_x > Integer.MAX_VALUE / 10 || _x < Integer.MIN_VALUE / 10)
return 0;
_x = _x * 10 + y;
x /= 10;
}
return _x;
}
}
class Solution {
public int[] twoSum(int[] nums, int target) {
int[] result = new int[2];
for (int i = 0; i < nums.length; i++) {
for (int j = 0; j < nums.length; j++) {
if (i != j && nums[i] + nums[j] == target) {
result[0] = i;
result[1] = j;
return result;
}
}
}
return result;
}
}