Skip to content

Commit

Permalink
Time: 0 ms (100%), Space: 49.5 MB (13.03%) - LeetHub
Browse files Browse the repository at this point in the history
  • Loading branch information
HassanMehmood413 committed Nov 22, 2024
1 parent 2e2f757 commit 510d6e6
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions 0088-merge-sorted-array/0088-merge-sorted-array.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,19 @@
* @return {void} Do not return anything, modify nums1 in-place instead.
*/
var merge = function (nums1, m, nums2, n) {
let i = 0
while (i <= nums2.length - 1) {
nums1[m] = nums2[i]
m++
i++
let l = 0
for (let i = nums1.length - 1; i >= 0; i--) {
if (nums2[l] == undefined) {
break
}
if (nums1[i] == 0) {
nums1[i] = nums2[l]
l++
}
else {
break
}
}
return nums1.sort((a, b) => a - b)

};
nums1 = nums1.sort((a, b) => a - b)
return nums1.length
};

0 comments on commit 510d6e6

Please sign in to comment.