摘要:
public int maxArea(int[] height) { // 初始化最大盛水量为0 int res = 0; // 使用双指针,i从数组起始位置开始,j从数组末尾开始 int i = 0; int j = height.length - 1; // 双指针向中间移动,直到相遇 whil 阅读全文
posted @ 2025-05-19 21:11
星星永远发着光
阅读(12)
评论(0)
推荐(0)
摘要:
class Solution { public boolean isPalindrome(int x) { // 处理负数情况:所有负数都不是回文数 if(x < 0) { return false; // 示例:-121 反转后121-,明显不匹配 } int cur = 0; // 存储反转后的 阅读全文
posted @ 2025-05-19 19:14
星星永远发着光
阅读(9)
评论(0)
推荐(0)
摘要:
class Solution { public int reverse(int x) { int rev = 0; // 存储反转结果 // 循环处理每一位数字(包含负数情况) while (x != 0) { /* 关键溢出检查:在计算结果前进行预判 Integer.MAX_VALUE = 214 阅读全文
posted @ 2025-05-19 16:12
星星永远发着光
阅读(24)
评论(0)
推荐(0)
摘要:
class Solution { public String convert(String s, int numRows) { // 处理行数为1的特殊情况(无需变换直接返回) if (numRows == 1) { return s; } // 初始化每行的字符串容器(注意:Java数组需用Arr 阅读全文
posted @ 2025-05-19 15:17
星星永远发着光
阅读(7)
评论(0)
推荐(0)

浙公网安备 33010602011771号