添加 0406.根据身高重建队列.md Scala版本

This commit is contained in:
ZongqinWang
2022-06-13 22:12:49 +08:00
parent 6867c9c5bf
commit 17208d8929

View File

@ -354,8 +354,27 @@ function reconstructQueue(people: number[][]): number[][] {
};
```
### Scala
```scala
object Solution {
import scala.collection.mutable
def reconstructQueue(people: Array[Array[Int]]): Array[Array[Int]] = {
val person = people.sortWith((a, b) => {
if (a(0) == b(0)) a(1) < b(1)
else a(0) > b(0)
})
var que = mutable.ArrayBuffer[Array[Int]]()
for (per <- person) {
que.insert(per(1), per)
}
que.toArray
}
}
```
-----------------------