常用演算法整理
去除整數陣列中的重複數字
import java.util.*;
public class Main {
public static Integer[] removeDuplicates(Integer[] nums){
return new LinkedHashSet<>(Arrays.asList(nums)).toArray(new Integer[0]);
}
}
整數陣列從小到大排序
import java.util.*;
public class Main {
public static Integer[] sortSmallToLarge(Integer[] nums){
Arrays.sort(nums);
return nums;
}
}