We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a192c2d commit 87aabdaCopy full SHA for 87aabda
June-LeetCoding-Challenge/06-Queue-Reconstruction-By-Height/Queue-Reconstruction-By-Height.kt
@@ -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