Hi Saurabh,

Here are the steps:

Assume arrays A[n] and B[m]

- x = A[k]
- Look for value (x-1) in array B. Binary search will take O(logm) time.
- If no such value is present then return x
- If such a value is present at index l, then return (A[k-l] > B[l]? A[k-l]
: B[l])

As you can see there is only 1 binary search performed. Rest is the constant
time operation.

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to