avatar
帮着看到G家题# JobHunting - 待字闺中
s*r
1
Given two sorted postive integer arrays A(n) and B(n),each array is
decreased order sorted. find n smallest sum of pair of (a, b), a belong to A
, b belong to B
Is there a O(n) algorithm ?
avatar
c*t
2
我觉得没有O(n)解

A

【在 s****r 的大作中提到】
: Given two sorted postive integer arrays A(n) and B(n),each array is
: decreased order sorted. find n smallest sum of pair of (a, b), a belong to A
: , b belong to B
: Is there a O(n) algorithm ?

avatar
M*5
3
我对这道题没有很明白,能否给个解释?

【在 c********t 的大作中提到】
: 我觉得没有O(n)解
:
: A

avatar
c*t
4
我理解是找最小的 n个 sum. sum是指 a+b

【在 M********5 的大作中提到】
: 我对这道题没有很明白,能否给个解释?
avatar
l*n
5


【在 c********t 的大作中提到】
: 我理解是找最小的 n个 sum. sum是指 a+b
avatar
c*g
6
直接用merge 有什么问题吗?
每次比较A[i]+B[j+1]和A[i+1]和B[j]

A

【在 s****r 的大作中提到】
: Given two sorted postive integer arrays A(n) and B(n),each array is
: decreased order sorted. find n smallest sum of pair of (a, b), a belong to A
: , b belong to B
: Is there a O(n) algorithm ?

avatar
s*n
7
感觉可以直接找a和b中Na+Nb个smallest数
Na是a中最小的若干数
Nb是b中最小的若干数
Na * Nb = n
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。