Array Question 5

Home / Java Practice Question / Array Question 5

Array Question 5


Question 5. Write a Program to remove duplicacy from array.

Program-


class Solution {

    int remove_duplicate(int A[],int N){   

        int pointer=0;

        for(int i=1;i<N;i++){

            if(A[pointer]!=A[i]){

                pointer++;

                A[pointer]=A[i];

            }

        }

        return ++pointer;

    }

}