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
Below is the generic answer in java code for any number of missing numbers in a given array
//assumes that there are no duplicates
a = [1,2,3,4,5]
b = [1,2,5]
a-b=[3,4]
public list find(int[] input){
int[] a= new int[] {1,2,3,4,5};//create a new array without missing numbers
List l = new ArrayList();//list for missing numbers
Map m = new HashMap();
//populate a hashmap with the elements in the new array
for(int i=0;i