Closest pair sum in two sorted arrays

后端 未结 3 462
感动是毒
感动是毒 2021-01-03 04:40

Given two sorted arrays of integers, a and b, and an integer c, I have to find i,j such that:

a[i] + b[j]         


        
3条回答
  •  有刺的猬
    2021-01-03 04:55

    I think you dont have to search the whole array b[] next time.......u have to search in between starting of array b and the lowest bound u found till now....for the next element in a[].It would definitely reduce your time complexity...and when u find the given target 'c' you must stop your search.

提交回复
热议问题