1. 程式人生 > >LeetCode 406: Queue Reconstruction

LeetCode 406: Queue Reconstruction

return [] turn list .so [0 etc class const

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