You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//int[] num = {7,-1,14,-12,-8,7,2,-15,8,8,-8,-14,-4,-5,7,9,11,-4,-15,-6,1,-14,4,3,10,-5,2,1,6,11,2,-2,-5,-7,-6,2,-15,11,-6,8,-4,2,1,-1,4,-6,-15,1,5,-15,10,14,9,-8,-6,4,-6,11,12,-15,7,-1,-9,9,-1,0,-4,-1,-12,-2,14,-9,7,0,-3,-4,1,-2,12,14,-10,0,5,14,-1,14,3,8,10,-8,8,-5,-2,6,-11,12,13,-7,-12,8,6,-13,14,-2,-5,-11,1,3,-6};
//int[] num = {-4,-2,1,-5,-4,-4,4,-2,0,4,0,-2,3,1,-5,0};
//int[] num = {1,2,-2,-1};
//int[] num = {-4,-2,1,-5,-4,-4,4,-2,0,4,0,-2,3,1,-5,0};
//int[] num = {-2,0,0,2,2};
//Arrays.sort(num);
sort(num, 0, num.length - 1);
int[] newT = removeDuplicate(num);
print(newT);
System.out.printf("\n");
ArrayList<ArrayList<Integer>> result = threeSum(num);
System.out.printf(result.toString());
}
publicstaticint[] removeDuplicate(int[] input){
intlen = input.length;
int[] output = newint[len];
intj = 0;
for (inti = 0; i < len; i ++) {
if (i > 0) {
while (input[i] == input[i-1]){
i ++;
}
}
output[j] = input[i];
j++;
}
returnoutput;
}
publicstaticvoidprint(intnum[]){
System.out.printf("After sort: \n");
for (inti = 0; i < num.length; i++) {
System.out.printf("%d ", num[i]);
}
System.out.printf("\n");
}
/* return the middle position. all the data below middle value will