Notice
Recent Posts
Recent Comments
Link
250x250
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- string
- 변수
- CSS
- 백준
- math
- sorting
- JS
- vue.js
- Algorithm
- github
- leetcode
- hash table
- HTML
- 파이썬
- 알고리즘
- scss
- 자료형
- 컴포넌트
- greedy
- 프로그래머스
- array
- dynamic programming
- computed
- java
- Python
- SasS
- JavaSceipt
- 코딩테스트
- JavaScript
- 자료구조
Archives
- Today
- Total
Posis
[LeetCode][JavaScript] 88. Merge Sorted Array 본문
[LeetCode][JavaScript] 88. Merge Sorted Array
문제 출처: https://leetcode.com/problems/merge-sorted-array/
Merge Sorted Array - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com

[직접 푼 코드]
var merge = function (nums1, m, nums2, n) {
nums1.splice(m, n, ...nums2);
nums1.sort((a, b) => a - b);
return nums1;
};
[문제 풀이]
1. nums1의 3번째 위치부터 3개를 지우고 nums2를 넣어줍니다. (splice 메서드)
2. 오름차순으로 정렬합니다. (sort 메서드)
p.s 어떻게 설명해야 할지 몰라서 직접적으로 설명했습니다.ㅜ
알고리즘 스터디: https://github.com/ROUTINE-STUDY/Algorithm
GitHub - ROUTINE-STUDY/Algorithm: 초보 알고리즘 스터디 / 누구나 참여 가능
초보 알고리즘 스터디 / 누구나 참여 가능 :runner:. Contribute to ROUTINE-STUDY/Algorithm development by creating an account on GitHub.
github.com
누구나 참여 가능한 알고리즘 스터디입니다.
알고리즘뿐만 아니라 개발을 하면서 겪은 이슈, 이론을 정리하는 Routine-Study를 운영 중입니다.
728x90
'알고리즘 > leetcode' 카테고리의 다른 글
[LeetCode][JavaScript] 9. Palindrome Number (0) | 2021.08.07 |
---|---|
[LeetCode][JavaScript] 561. Array Partition I (0) | 2021.07.29 |
[LeetCode][JavaScript] 1436. Destination City (0) | 2021.07.29 |
[LeetCode][JavaScript] 70. Climbing Stairs (0) | 2021.07.29 |
[LeetCode][JavaScript] 1323. Maximum 69 Number (0) | 2021.07.29 |