406. Queue Reconstruction by Height

这怎么排啊。。。毫无头绪呢。。。想到的有应该先以k为主?再辅以h?

看了大佬们的思路,妙啊。。

class Solution {
    public int[][] reconstructQueue(int[][] people) {
        Arrays.sort( people , new Comparator<int[]>(){
            public int compare( int[] a , int[] b ){
                if( a[0] == b[0] )return a[1] - b[1];
                else return -a[0] + b[0];

            }
        });
        
        List<int[]> res = new LinkedList<>();
        
        for( int[] it : people )
            res.add( it[ 1 ] , it );
        
        return res.toArray( new int[ people.length][] );
    }
}

406. Queue Reconstruction by Height

先 按照身高从高到低排列,将tallest排完之后,将second tallest的插入