LeetCode 406: Queue Reconstruction

Posted keepshuatishuati

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LeetCode 406: Queue Reconstruction相关的知识,希望对你有一定的参考价值。

This is SO AWESOME solution.

class Solution {
    public int[][] reconstructQueue(int[][] people) {
        Arrays.sort(people, (p1, p2) -> p1[0] != p2[0] ? p2[0] - p1[0] : p1[1] - p2[1]);
        List<int[]> result = new ArrayList<>();
        for (int[] p : people) {
            result.add(p[1], p);
        }
        return result.toArray(new int[people.length][]);
    }
}

 

以上是关于LeetCode 406: Queue Reconstruction的主要内容,如果未能解决你的问题,请参考以下文章

[leetcode] 406.Queue Reconstruction by Height

[LeetCode] 406. Queue Reconstruction by Height(按身高重排队列)

LeetCode 406.Queue Reconstruction by Height

LeetCode 406. Queue Reconstruction by Height

LeetCode 406. Queue Reconstruction by Height

leetcode 406. Queue Reconstruction by Height 根据身高重建队列(中等)