Skip to content

Instantly share code, notes, and snippets.

@cg4jins
Created July 3, 2019 00:47
Show Gist options
  • Save cg4jins/c8a54806131748020cda022807c4dbf0 to your computer and use it in GitHub Desktop.
Save cg4jins/c8a54806131748020cda022807c4dbf0 to your computer and use it in GitHub Desktop.
class Solution {
fun solution(array: IntArray, commands: Array<IntArray>): IntArray {
var answer = mutableListOf<Int>()
for (command in commands) {
var subList = array.toList()
.subList(command[0] - 1, command[1])
subList = subList.sorted()
answer.add(subList[command[2] - 1])
}
return answer.toIntArray()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment