@Arun: I left out that you sort the array by absolute values and compare absolute values of adjacent elements. The sorted array would be {-2, 4, -8, 9, 10, 12, 14, 17, -20}. Then abs(abs(-8) - abs(9)) is the smallest difference. Dave Dave
On Friday, July 27, 2012 11:21:52 PM UTC-5, Arun Kindra wrote: > @Dave Sir : Sir if u sort the array(given above) the array would be: > -20,-8-2,4,9,10,12,14,17, and according to ur suggestion, the only ans is > {9,10}...but one of the ans {9,-8} is also possible.......as he is asking > the difference in absolute values. > > correct me if i m wrong... > -- 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/-/xqgVivlgw68J. To post to this group, send email to algogeeks@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.