일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 코딩테스트
- 프로그래머스
- secondlowestgrade
- 정보과학과
- Code Jam 2022
- ESXi 업데이트
- C++
- 방송통신대학교 대학원 정보과학과
- 하늘과 바람과 별과 시
- nestedlists
- MySQL
- Kubernetes
- K8S
- ingress-nginx
- Python
- on-prem
- swift
- 파이썬
- 하늘과 바람과 별과 詩
- GitLab
- openebs
- 3D PRINTING
- Qualification Round
- 2022
- LEVEL 2
- Code Jam
- hackerrank
- 방통대 대학원 정보과학과
- 해커랭크
Archives
- Today
- Total
공대생의 비망록
[프로그래머스][Lv. 1] K번째 수 Swift 풀이 본문
https://programmers.co.kr/learn/courses/30/lessons/42748
코딩테스트 연습 - K번째수
[1, 5, 2, 6, 3, 7, 4] [[2, 5, 3], [4, 4, 1], [1, 7, 3]] [5, 6, 3]
programmers.co.kr
풀이는 추후에 차차 올리도록 하겠습니다...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
import Foundation
func solution(\_ array:\[Int\], \_ commands:\[\[Int\]\]) -> \[Int\] {
var ans = \[Int\]()
var temp = \[Int\]()
for command in commands {
temp = array
temp.removeLast(temp.count - command\[1\])
temp.removeFirst(command\[0\] - 1)
temp.sort()
ans.append(temp\[command\[2\] - 1\])
}
return ans
}
|
cs |
'Programming Language > Swift' 카테고리의 다른 글
[프로그래머스][Lv. 1] 체육복 Swift 풀이 (0) | 2022.03.14 |
---|---|
[프로그래머스][Lv. 1] 모의고사 Swift 풀이 (0) | 2022.03.14 |
[프로그래머스][Lv. 1] 소수 만들기 Swift 풀이 (0) | 2022.03.14 |
[프로그래머스][Lv. 1] 내적 Swift 풀이 (0) | 2022.03.14 |
[프로그래머스][Lv. 1] 음양 더하기 Swift 풀이 (0) | 2022.03.14 |
Comments