Leetcode - Merge Sorted Array (Python)

preview_player
Показать описание
January 2021 Leetcode Challenge
Leetcode - Merge Sorted Array #88
Рекомендации по теме
Комментарии
Автор

Thank you for this solution. Seems like everyone on YouTube solves this question the same way (starting from the end and using the greater val)

brandonblackwell
Автор

If you set your pointer i to the "real" end of nums1 (i.e. m - 1), pointer j to n - 1 for nums2, and k to be m + n - 1 and then filling in nums[k] with the larger value of nums1[i] and nums2[j] and decrementing the pointer which value is used and k will lead to a solution without additional memory for nums1.

maplelegend
join shbcf.ru