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
您的题解链接
输入数据为 [0], 0, [1], 1,预期结果为 [1] ,实际结果为 [undefined]。
41-45行,在处理A数组为空的情况时,遗漏了return。
if (!A.length || !m) { for (let i = 0; i < n; i++) { A[i] = B.shift() } return // 此处应return }
否则继续往下执行至58-63行时,由于43行的shift方法已经将B数组的全部元素弹出,B[bIndex]成为了undefined,造成结果错误。
// 数组 A 遍历完,B 还有 if (aIndex < 0) { while (bIndex >= 0) { A[mIndex--] = B[bIndex--] // 此时的 B[bIndex] 为undefined!! } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
您的题解链接
Bug复现
输入数据为 [0], 0, [1], 1,预期结果为 [1] ,实际结果为 [undefined]。
原因
41-45行,在处理A数组为空的情况时,遗漏了return。
否则继续往下执行至58-63行时,由于43行的shift方法已经将B数组的全部元素弹出,B[bIndex]成为了undefined,造成结果错误。
The text was updated successfully, but these errors were encountered: