V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
• 请不要在回答技术问题时复制粘贴 AI 生成的内容
phx13ye
V2EX  ›  程序员

求讲解 Median of Two Sorted Arrays 转换为 TopK 问题?

  •  
  •   phx13ye ·
    Alwayswithme · May 19, 2015 · 2607 views
    This topic created in 4002 days ago, the information mentioned may be changed or developed.
    比较两个数组的中位数之后, 排除那部分蒙圈了
    3 replies    2015-05-19 17:04:07 +08:00
    phx13ye
        2
    phx13ye  
    OP
       May 19, 2015
    @deepreader
    if A[m/2]>B[n/2] and k>m/2+n/2, then disregard B_left and B[n/2]
    if A[m/2]>B[n/2] and k<=m/2+n/2, then disregard A_right and A[m/2]
    if A[m/2]<=B[n/2] and k>m/2+n/2, then disregard A_left and A[m/2]
    if A[m/2]<=B[n/2] and k<=m/2+n/2, then disregard B_right and B[n/2]
    这里怎么理解
    deepreader
        3
    deepreader  
       May 19, 2015
    @phx13ye 两个数组被分成四段,case 1的话,你要找的target则不可能在四段中值最小的那一段,其他的类推。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1289 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 16:50 · PVG 00:50 · LAX 09:50 · JFK 12:50
    ♥ Do have faith in what you're doing.