it can be done with o(n) start with a pointer on both sides.beginning as well as end.take their sum.if sum is less than x move left pointer towards right.if sum is greater than x move right pointer towards left.if sum is equal to x move left pointer right and right pointer left. and again take sum.continue doing like this .it will take maximum o(n) time
--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. 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 -~----------~----~----~----~------~----~------~--~---
