Program to remove duplicate numbers from sorted list
/*Program to remove duplicate numbers from sorted list*/
import java.util.*;
public class Prgrm {
public static void main(String[] args) {
ArrayList<Integer> al = new ArrayList<Integer>();
int lastindex=0;
int[] arr={2,3,6,6,8,9,10,10,10,10,10,10,12,12,12,14,15,16};
for (int i=0;i<arr.length-1 ;i++ ) {
if(arr[i]!=arr[i+1]){
al.add(arr[i]);
lastindex=i;
}
}
al.add(arr[lastindex+1]);
for (int i=0;i<al.size() ;i++ ) {
System.out.println(al.get(i));
}
}
}
import java.util.*;
public class Prgrm {
public static void main(String[] args) {
ArrayList<Integer> al = new ArrayList<Integer>();
int lastindex=0;
int[] arr={2,3,6,6,8,9,10,10,10,10,10,10,12,12,12,14,15,16};
for (int i=0;i<arr.length-1 ;i++ ) {
if(arr[i]!=arr[i+1]){
al.add(arr[i]);
lastindex=i;
}
}
al.add(arr[lastindex+1]);
for (int i=0;i<al.size() ;i++ ) {
System.out.println(al.get(i));
}
}
}
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment