ya much works is done by above candidate. i would like to say..use 2 ptrs one from beginning & another from end take sum=a[start]+a[end]; find if sum>num end-- else if sum<num start++; else //sum==num found;
time compexcity O(n) sizeof array space compexcity O(1) Regards Shashank Mani "Don't Be Evil U Can Learn While U Earn" Computer Science & Engg. Birla Institute of Technology,Mesra Cell +91-9718508004 -- 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.