본문 바로가기
Coding Test/LeetCode

[LeetCode] (Sorting and Searching) Lv Easy. Merge Sorted Array

by song.ift 2023. 1. 22.

https://leetcode.com/explore/interview/card/top-interview-questions-easy/96/sorting-and-searching/587/

 

Explore - LeetCode

LeetCode Explore is the best place for everyone to start practicing and learning on LeetCode. No matter if you are a beginner or a master, there are always new topics waiting for you to explore.

leetcode.com

 

/**
 * @param {number[]} nums1
 * @param {number} m
 * @param {number[]} nums2
 * @param {number} n
 * @return {void} Do not return anything, modify nums1 in-place instead.
 */
var merge = function (nums1, m, nums2, n) {
    nums1.splice(m);
    nums1.push(...nums2);
    return nums1.sort((a, b) => a - b);
};

GitHub : https://github.com/developeSHG/Algorithm-LeetCode/tree/main/merge-sorted-array

 

GitHub - developeSHG/Algorithm-LeetCode: 릿코드 소스코드

릿코드 소스코드. Contribute to developeSHG/Algorithm-LeetCode development by creating an account on GitHub.

github.com

 

댓글