15 条题解
-
1
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String n = sc.next(); int first = 0, end = n.length() - 1; boolean isPalindrome = true; while (first < end) { if (n.charAt(first) == n.charAt(end)) { first++; end--; } else { isPalindrome = false; break; } } if (isPalindrome) { System.out.println("yes"); } else { System.out.println("no"); } } }
双指针的算法思想,可以去了解了解,我这里是java写的
信息
- ID
- 32
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 6
- 标签
- 递交数
- 4451
- 已通过
- 1459
- 上传者