카타 7급 Two Oldest Ages

Kotlin[ | ]

package solution
fun twoOldestAges(ages: List<Int>): List<Int> {
    val a = ages.sortedDescending()
    return listOf(a[1], a[0])
}
package solution
fun twoOldestAges(ages: List<Int>): List<Int> {
  return ages.sorted().takeLast(2)
}
package solution
fun twoOldestAges(ages: List<Int>): List<Int> {
  return ages.sortedDescending().take(2).reversed()
}
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}