for 2nd part of 1st question, when array has become sorted

for ex: 3 5 10 16 17 35 40 56 67 and num is 33
becomes : 3 5 10 16 16 ..............
make array of 17 elements s[0,0,1,........2..]
s[16] = 2 means we find a duplicate hense resultu
int m = (num%2==1)?(num/2+1):(num/2)
for (int i=0;i<n;i++)
{
if(arr[i]<num&&arr[i]>m){arr[i]=num-arr[i]}
}
now find for duplicate in array till the no. <= m

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/MCwjsX-Kg1IJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to