Skip to content

Commit 87aabda

Browse files
add kotlin solution for 406 Queue-Reconstruction-By-Height.kt
1 parent a192c2d commit 87aabda

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class QueueReconstructionbyHeightKotlin406 {
2+
fun reconstructQueue(people: Array<IntArray>): Array<IntArray> {
3+
people.sortWith(Comparator { t, t2 ->
4+
when {
5+
t[0] == t2[0] -> compareValues(t[1], t2[1])
6+
else -> compareValues(t2[0], t[0])
7+
}
8+
})
9+
val result: MutableList<IntArray> = ArrayList()
10+
people.forEach {
11+
result.add(it[1], it)
12+
}
13+
return result.toTypedArray()
14+
}
15+
}

0 commit comments

Comments
 (0)