V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
phx13ye
V2EX  ›  程序员

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

  •  
  •   phx13ye ·
    Alwayswithme · 2015-05-19 15:09:02 +08:00 · 2066 次点击
    这是一个创建于 3265 天前的主题,其中的信息可能已经有所发展或是发生改变。
    比较两个数组的中位数之后, 排除那部分蒙圈了
    3 条回复    2015-05-19 17:04:07 +08:00
    phx13ye
        2
    phx13ye  
    OP
       2015-05-19 16:53:49 +08:00
    @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  
       2015-05-19 17:04:07 +08:00
    @phx13ye 两个数组被分成四段,case 1的话,你要找的target则不可能在四段中值最小的那一段,其他的类推。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2873 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 11:56 · PVG 19:56 · LAX 04:56 · JFK 07:56
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.