Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- Counting
- string
- greedy
- 코딩테스트
- Binary Search
- Data Structure
- 구현
- array
- simulation
- geometry
- database
- bit manipulation
- Number Theory
- Math
- java
- Binary Tree
- implement
- 파이썬
- Stack
- Class
- Method
- 코테
- two pointers
- Matrix
- SQL
- Tree
- sorting
- dynamic programming
- 자바
- hash table
Archives
- Today
- Total
코린이의 소소한 공부노트
[LeetCode/Easy] 1470. Shuffle the Array 본문
1. Input
1) int 배열 nums
2) 정수 n
3) nums의 요소는 [x1, x2, ..., xn, y1, y2, ..., yn]의 2n개로 이루어져 있다.
2. Output
1) nums의 배열을 [x1, y1, x2, y2, ..., xn, yn]의 형태로 재배열한 결과
3. Constraint
1) 1 <= n <= 500
2) nums.length == 2n
3) 1 <= nums[i] <= 10^3
4. Example
Input: nums = [1,1,2,2], n = 2 -> Output: [1,2,1,2]
5. Code
1) 첫 코드(2022/06/02)
int[] result = new int[2*n];
for(int i=0 ; i<n ; i++){
result[2*i] = nums[i];
result[2*i+1] = nums[n+i];
}
return result;
'코딩테스트 풀이 > JAVA' 카테고리의 다른 글
[LeetCode/Easy] 1480. Running Sum of 1d Array (0) | 2022.12.26 |
---|---|
[LeetCode/Easy] 1475. Final Prices With a Special Discount in a Shop (0) | 2022.12.26 |
[LeetCode/Easy] 448. Find All Numbers Disappeared in an Array (0) | 2022.12.25 |
[LeetCode/Easy] 441. Arranging Coins (0) | 2022.12.25 |
[LeetCode/Easy] 1464. Maximum Product of Two Elements in an Array (0) | 2022.12.25 |