class arrayDublicate{
//Remove Array Dublicate With Extra Space
public static void main(String[] args){
int[] arr={1,2,2,3,4,5,5,6};
int n=arr.length;
int[] copyArr=new int[n];
int j=0;
for(int i=0;i<n-1;i++){
if(arr[i]!=arr[i+1]){
copyArr[j]=arr[i];
j+=1;
}
}
for(int i=0;i<j;i++){
System.out.println(copyArr[i]);
}
}
}
Comments
Post a Comment