티스토리 뷰
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
- yarn
- ubuntu
- 다이나믹
- S3
- java
- 하이브
- 파이썬
- hbase
- Python
- SPARK
- error
- AWS
- HDFS
- airflow
- build
- Linux
- SQL
- mysql
- emr
- Hadoop
- nodejs
- 정올
- 백준
- bash
- oozie
- 하둡
- 알고리즘
- HIVE
- 오류
- Tez
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함