We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
原题链接
const merge = function(nums1, m, nums2, n) { let i = m - 1 let j = n - 1 let k = m + n - 1 while (i >= 0 || j >= 0) { if(i < 0) { nums1[k--] = nums2[j--] } else if (j < 0) { nums1[k--] = nums1[i--] } else if (nums1[i] < nums2[j]) { nums1[k--] = nums2[j--] } else { nums1[k--] = nums1[i--] } } return nums1 }
The text was updated successfully, but these errors were encountered:
应该可以不判断 i,因为当j< 0 后剩下nums [0, i] 是默认顺序排的可以省略
Sorry, something went wrong.
No branches or pull requests
原题链接
逆向双指针
The text was updated successfully, but these errors were encountered: