Remove duplicates from integer array

前端 未结 23 2400
执念已碎
执念已碎 2020-12-01 18:52

I having a problem with coding this:

Write a static method named removeDuplicates that takes as input an array of integers and returns as a result a new

23条回答
  •  悲哀的现实
    2020-12-01 19:11

    public class Foo {

    public static void main(String[] args) {
        //example input
        int input[] = new int[]{1, 6 , 5896, 5896, 9, 100,7, 1000, 8, 9, 0, 10, 90, 4};
        //use list because the size is dynamical can change
        List result = new ArrayList();
    
        for(int i=0; i

    } output: 1, 6, 5896, 9, 100, 7, 1000, 8, 0, 10, 90, 4,

提交回复
热议问题