티스토리 뷰
https://programmers.co.kr/learn/courses/30/lessons/42748?language=scala
알고리즘 연습 - K번째수 | 프로그래머스
실행 결과가 여기에 표시됩니다.
programmers.co.kr
object Solution01 extends App {
var array = Vector(1, 5, 2, 6, 3, 7, 4)
var commands = Vector(Vector(2, 5, 3), Vector(4, 4, 1), Vector(1, 7, 3))
def solution(array: Vector[Int], commands: Vector[Vector[Int]]): Vector[Int] = {
def innerSol(array: Vector[Int], command: Vector[Int]): Int = {
var from = command(0) - 1
var to = command(1)
var index = command(2) - 1
return array.slice(from, to).sortWith(_ < _)(index)
}
return commands.map(innerSol(array, _)).collect({ case i: Int => i })
}
solution(array, commands)
}
반응형
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 백준
- 다이나믹
- oozie
- HDFS
- mysql
- 하이브
- yarn
- error
- hbase
- Linux
- ubuntu
- AWS
- 하둡
- 정올
- build
- nodejs
- airflow
- java
- Tez
- S3
- HIVE
- SQL
- Python
- 오류
- 알고리즘
- SPARK
- 파이썬
- emr
- Hadoop
- bash
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함