ãµã¯ãµã¯èªãã¦ãã¢ããªéå®ã®æ©è½ãå¤æ°ï¼
ã¿ã°ããã¹ã¦è¡¨ç¤º
fun <T : Comparable<T>> List<T>.quickSort(): List<T> = when { size < 2 -> this else -> { val pivot = first() val (smaller, greater) = drop(1).partition { it <= pivot } smaller.quickSort() + pivot + greater.quickSort() } } fun main() { print(listOf(5, 0, 1, 5, 3, 7, 4, 2).quickSort()) }
ã©ã³ãã³ã°
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}