An algorithm to find the nth largest number in two arrays of size n

前端 未结 3 1808
我在风中等你
我在风中等你 2021-02-09 05:56

I have this question:

Given two sorted lists (stored in arrays) of size n, find an O(log n) algorithm that computes the nth largest element in the union

3条回答
  •  旧时难觅i
    2021-02-09 06:20

    Evgeny Kluev gives a better answer - mine was O(n log n) since i didn't think about them as being sorted.

    what i can add is give you a link to a very nice video explaining binary search, courtesy of MIT:

    https://www.youtube.com/watch?v=UNHQ7CRsEtU

提交回复
热议问题