Problem 1 : Given an array of sorted number of size N and contains numbers in range 1 to N-1. Find the smallest missing number.
Binary Search: check whether a[mid] != mid+ 1
Binary Search: check whether a[mid] != mid+ 1
Problem 2 : Given an array of size N, find all duplicate numbers. ==> also contains numbers in range 1 to N-1.
Read full article from Algorithms and Me: Curious case of Missing and repeating number Part -2int find_duplicates(int a[], int n){int i =0;for(i=0; i<n; i++){if(a[abs(a[i])] >0){a[abs(a[i])] = - a[abs(a[i])];}elseprintf("\n %d" , abs(a[i]));}}