部分题目

This commit is contained in:
2025-08-31 22:29:07 +08:00
parent 92ee8e1383
commit 4cd15619f9
8 changed files with 60 additions and 5 deletions

View File

@@ -0,0 +1,4 @@
package cn.celess.common;
public class ListNode {
}

View File

@@ -0,0 +1,36 @@
package cn.celess.leetcode.test125;
class Solution {
public boolean isPalindrome(String s) {
int left =0;
int right = s.length()-1;
while(left <= right){
char leftChar = Character.toLowerCase(s.charAt(left));
char rightChar = Character.toLowerCase(s.charAt(right));
if(!((int)leftChar>=(int)'0' && (int)leftChar<=(int)'9') && !((int)leftChar>=(int)'a' && (int)leftChar<=(int)'z')){
left++;
continue;
}
if(!((int)rightChar>=(int)'0' && (int)rightChar<=(int)'9') && !((int)rightChar>=(int)'a' && (int)rightChar<=(int)'z')){
right--;
continue;
}
if (leftChar != rightChar){
return false;
}
left++;
right--;
}
return true;
}
}
class Main {
public static void main(String[] args) {
System.out.println(new Solution().isPalindrome("race a car"));
System.out.println(new Solution().isPalindrome("A man, a plan, a canal: Panama"));
}
}

View File

@@ -0,0 +1,15 @@
package cn.celess.leetcode.test147;
import cn.celess.common.ListNode;
class Solution {
public boolean hasCycle(ListNode head) {
return true;
}
}
class Main {
public static void main(String[] args) {
}
}

View File

@@ -1,4 +1,4 @@
package cn.celess.leetcode.topinterview150.test26;
package cn.celess.leetcode.test26;
public class Main {
public static void main(String[] args) {

View File

@@ -1,4 +1,4 @@
package cn.celess.leetcode.topinterview150.test26;
package cn.celess.leetcode.test26;
class Solution {
public int removeDuplicates(int[] nums) {

View File

@@ -1,4 +1,4 @@
package cn.celess.leetcode.topinterview150.test27;
package cn.celess.leetcode.test27;
import java.util.Arrays;

View File

@@ -1,4 +1,4 @@
package cn.celess.leetcode.topinterview150.test27;
package cn.celess.leetcode.test27;
class Solution {
public int removeElement(int[] nums, int val) {

View File

@@ -1,4 +1,4 @@
package cn.celess.leetcode.topinterview150.test80;
package cn.celess.leetcode.test80;
public class Solution {