A little Clarification over Follow up1 (when both the arrays are sorted, optimize your code?)

  • 0

    The question is stating that we have to find all the possible interaction between the arrays.
    Taking this into account we have to keep one array's value in a map and iterate over the other array.(a brute force- i.e. when the array was not sorted)
    But even when both the arrays are sorted we have to search and store in the map in O(n).
    That is how can we use Binary Search in such a situation..?

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.