和题解里方法一几乎一样但是超时
class Solution {public int maxEnvelopes(int[][] envelopes) {int n = envelopes.length;Arrays.sort(envelopes,new Comparator<int[]>(){public int compare(int[] arr1,int[] arr2){if(arr1[0]!=arr2[0]){return arr1[0]-arr2[0];}else{return arr1[1]-arr2[1];} }});int[] dp = new int[n];int max = 1;for(int i=0;i<n;i++){dp[i]=1;for(int j=i-1;j>=0;j--){if(envelopes[i][0]>envelopes[j][0]&&envelopes[i][1]>envelopes[j][1]){dp[i] = Math.max(dp[i],dp[j]+1); }}max = Math.max(max,dp[i]);}return max;}
}