try for this {100,6,101,11} On Sep 23, 7:40 pm, Nishant Agarwal <nishant.agarwa...@gmail.com> wrote: > int minDiff(int arr[], int arr_size) > { > int min_diff = arr[1] - arr[0]; > int max_element = arr[0]; > int i; > for(i = 1; i < arr_size; i++) > { > if(arr[i] - max_element < min_diff) > min_diff = arr[i] - max_element; > if(arr[i] > max_element) > max_element = arr[i]; > } > return min_diff; > > } > > On Mon, Sep 20, 2010 at 10:38 AM, Srinivas > <lavudyasrinivas0...@gmail.com>wrote: > > > > > > > 2 nos with min diff > > given an array of size n. find 2 numbers from array whose difference > > is least in O(n) w/o > > using xtra space( i mean constant space) > > > -- > > You received this message because you are subscribed to the Google Groups > > "Algorithm Geeks" group. > > To post to this group, send email to algoge...@googlegroups.com. > > To unsubscribe from this group, send email to > > algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com> > > . > > For more options, visit this group at > >http://groups.google.com/group/algogeeks?hl=en. > > -- > .... :-) > ***************************************** > Nishant Agarwal > Computer Science and Engineering > NIT Allahabad > *****************************************- Hide quoted text - > > - Show quoted text -
-- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.