How do you do this? The values are unsorted but are of [1..n]
Example array [3,1,2,5,7,8]
. Answer: 4, 6
I saw this solution in
works for any number of missing elements: you can format the code a little .. but it works on duplicate and non duplicate entries also:
public static void main(String args[] ) throws Exception {
Scanner input = new Scanner(System.in);
System.out.println("Enter no. of students in the class");
int N = input.nextInt();
List l = new ArrayList();
int Nn=N;
System.out.println("Enter the roll numbers");
for(int i=0;i