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
No description provided.
The text was updated successfully, but these errors were encountered:
/** * 给你两个按 非递减顺序 排列的整数数组 nums1 和 nums2,另有两个整数 m 和 n ,分别表示 nums1 和 nums2 中的元素数目。 * @param nums1 * @param m * @param nums2 * @param n */ function merge(nums1: number[], m: number, nums2: number[], n: number): void { // 初始化两个指针的指向,初始化 nums1 尾部索引k let i = m - 1; let j = n - 1; let k = m + n - 1; while (i >= 0 && j >= 0) { // 取较大的值,从末尾往前填补 if (nums1[i] >= nums2[j]) { nums1[k] = nums1[i]; i--; k--; } else { nums1[k] = nums2[j]; j--; k--; } } // nums2 留下的情况,特殊处理一下 while (j >= 0) { nums1[k] = nums2[j]; j--; k--; } }
Sorry, something went wrong.
No branches or pull requests
No description provided.
The text was updated successfully, but these errors were encountered: