一攀操、數(shù)組和容器
1撬码、數(shù)組的元素為List:
????// 構(gòu)建一個長度為s.length() + 1的數(shù)組frequencyBucket督怜,元素為List<Character>
????List<Character>[] frequencyBucket = new ArrayList[s.length() + 1];
2煞额、List的元素為數(shù)組:
????int[][] people = {{7, 0}, {4, 4}, {7, 1}, {5, 0}, {6, 1}, {5, 2}};
? ? // 構(gòu)建一個列表output一喘,其元素為int[]
????List<int[]> output = new LinkedList<>();
? ? for(int[] p : people){
? ? ? ????output.add(p[1], p);? // add方法會在指定的index上插入值,如果index上已有值涛碑,則將新值插入當前值之前
? ? }
? ? int n = people.length;
? ? int[][] = output.toArray(new int[n][2]);
二精堕、(待續(xù))