@Dave.. never mind... i understood what u meant... On May 20, 4:18 pm, SVIX <saivivekh.swaminat...@gmail.com> wrote: > @ I didn't get that... could u please elaborate a little more? > > for each integer, search for something sounds like O(n^2) > > On May 20, 7:26 am, Dave <dave_and_da...@juno.com> wrote: > > > > > > > > > @Amit: Use a hash table. For each integer x[i] in the array, search > > for k - x[i]. If found, x[i] and k - x[i] are your pair of integers. > > Otherwise, add x[i] to the hash table and advance the loop. Output > > "none" if you get to the end of the array without a hit. > > > Dave > > > On May 20, 6:38 am, amit <amitthecoo...@gmail.com> wrote: > > > > given an array of integers, and an integer k, find out two elements > > > from the array whose sum is k in O(n) time. if no such element exists > > > output none.
-- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. 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.