-
배열_프로그래머스_level1_k번째 수알고리즘/알고리즘 문제풀이 2021. 7. 5. 20:46
https://programmers.co.kr/learn/courses/30/lessons/42748?language=swift
import Foundation func solution(_ array:[Int], _ commands:[[Int]]) -> [Int] { var sol : [Int] = [] for command in commands { let firstIndex = command[0] - 1 let lastIndex = command[1] - 1 let selectedIndex = command[2] - 1 let slicedArray = array[firstIndex...lastIndex].sorted() sol.append(slicedArray[selectedIndex]) } return sol }
정답
'알고리즘 > 알고리즘 문제풀이' 카테고리의 다른 글
해시_프로그래머스_위장 (0) 2021.07.14 해시_LeetCode_N-Repeated Element in Size 2N Array (0) 2021.07.14 완전탐색_LeetCode_ContainsDuplicate (0) 2021.07.08 배열_프로그래머스_level2_가장 큰 수 (0) 2021.07.05 배열_백준_9237 (0) 2021.07.05