mirror of
https://github.com/CyC2018/Interview-Notebook.git
synced 2026-10-23 09:43:44 +00:00
Update Leetcode 题解 - 双指针.md
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
4eb6dfbdfe
commit
77f2319e35
@@ -81,7 +81,7 @@ Explanation: 1 * 1 + 2 * 2 = 5
|
||||
if (target < 0) return false;
|
||||
int i = 0, j = (int) Math.sqrt(target);
|
||||
while (i <= j) {
|
||||
int powSum = i * i + j * j;
|
||||
long powSum = (long) i * i + (long) j * j;
|
||||
if (powSum == target) {
|
||||
return true;
|
||||
} else if (powSum > target) {
|
||||
@@ -212,8 +212,6 @@ public void merge(int[] nums1, int m, int[] nums2, int n) {
|
||||
while (index2 >= 0) {
|
||||
if (index1 < 0) {
|
||||
nums1[indexMerge--] = nums2[index2--];
|
||||
} else if (index2 < 0) {
|
||||
nums1[indexMerge--] = nums1[index1--];
|
||||
} else if (nums1[index1] > nums2[index2]) {
|
||||
nums1[indexMerge--] = nums1[index1--];
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user