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
归并排序,JavaScript版的好像是不稳定的
The text was updated successfully, but these errors were encountered:
function merge(arr1, arr2) { let arr = []; while (arr1.length && arr2.length) { if (arr1[0] < arr2[0]) { arr.push(arr1.shift()); } else { arr.push(arr2.shift()); } } return [...arr, ...arr1, ...arr2];
} 这里在arr1和arr2都只有一个元素且它们的值相等的情况下,返回的新数组中它们的顺序是交换了的。
Sorry, something went wrong.
应该是 if (arr1[0] <= arr2[0]) 吧
if (arr1[0] <= arr2[0])
044e45d
@Colin3191 已更正,谢谢反馈
No branches or pull requests
归并排序,JavaScript版的好像是不稳定的
The text was updated successfully, but these errors were encountered: