Skip to content

Commit ab1f1d3

Browse files
author
zhangbo54
committed
init leetcode respo
1 parent ce9fe0c commit ab1f1d3

File tree

5 files changed

+222
-57
lines changed

5 files changed

+222
-57
lines changed

.idea/workspace.xml

Lines changed: 117 additions & 55 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/leetcode/_7_Reverse_Integer/Main.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,17 @@
44
* Created by zhangbo54 on 2019-03-01.
55
*/
66
public class Main {
7+
static
8+
class Solution {
9+
public int reverse(int x) {
10+
Long result = 0L;
11+
while (x != 0) {
12+
result = result * 10 + x % 10;
13+
x = x / 10;
14+
}
15+
return result > Integer.MAX_VALUE || result < Integer.MIN_VALUE ? 0 : result.intValue();
16+
}
17+
}
718
}
19+
20+

src/leetcode/_8_String_to_Integer_atoi/Main.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
public class Main {
77
public static void main(String[] args) {
88
Solution solution = new Solution();
9-
System.out.println(solution.myAtoi(" "));
9+
System.out.println(solution.isPalindrome(""));
1010
// Integer.parseInt("1" + Integer.MAX_VALUE);
1111
}
1212

1313
static
1414
class Solution {
15-
public int myAtoi(String str) {
15+
public int isPalindrome(String str) {
1616
str = str.trim();
1717
StringBuilder sb = null;
1818
boolean started = false;
@@ -53,4 +53,5 @@ public int myAtoi(String str) {
5353
}
5454
}
5555
}
56+
5657
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package leetcode._9_Palindrome_Number;
2+
3+
/**
4+
* Created by zhangbo54 on 2019-03-01.
5+
*/
6+
public class Main {
7+
public static void main(String[] args) {
8+
Solution solution = new Solution();
9+
System.out.println(solution.isPalindrome(1));
10+
// Integer.parseInt("1" + Integer.MAX_VALUE);
11+
}
12+
13+
static
14+
class Solution {
15+
public boolean isPalindrome(int x) {
16+
if (x < 0) {
17+
return false;
18+
}
19+
if (x < 10) {
20+
return true;
21+
}
22+
char[] charArray = String.valueOf(x).toCharArray();
23+
for (int i = 0, j = charArray.length - 1; i < j; i++, j--) {
24+
if (charArray[i] != charArray[j]) {
25+
return false;
26+
}
27+
}
28+
return true;
29+
}
30+
}
31+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy