avatar
k*t
1
Given an unsorted array of positive integers, is it possible to find a pair
of integers from that array that sum up to a given sum?
Constraints: This should be done in O(n) and in-place (without any external
storage like arrays, hash-maps) (you can use extra variables/pointers)
If this is not possible, can there be a proof given for the same?
感觉不存在这样的解法。但怎么证明?
avatar
r*g
2
best result I get:
http://www.ic.unicamp.br/~rezende/ensino/mo619/Chan,RefinedUppe

pair
external

【在 k****t 的大作中提到】
: Given an unsorted array of positive integers, is it possible to find a pair
: of integers from that array that sum up to a given sum?
: Constraints: This should be done in O(n) and in-place (without any external
: storage like arrays, hash-maps) (you can use extra variables/pointers)
: If this is not possible, can there be a proof given for the same?
: 感觉不存在这样的解法。但怎么证明?

avatar
l*8
3
不存在,因为在one pass的过程中丢失了前面的所有信息,所以对于数组中的任意一个
数字都不能确定前面是否有能配对的数字。

pair
external

【在 k****t 的大作中提到】
: Given an unsorted array of positive integers, is it possible to find a pair
: of integers from that array that sum up to a given sum?
: Constraints: This should be done in O(n) and in-place (without any external
: storage like arrays, hash-maps) (you can use extra variables/pointers)
: If this is not possible, can there be a proof given for the same?
: 感觉不存在这样的解法。但怎么证明?

avatar
d*t
4
RE

【在 l*****8 的大作中提到】
: 不存在,因为在one pass的过程中丢失了前面的所有信息,所以对于数组中的任意一个
: 数字都不能确定前面是否有能配对的数字。
:
: pair
: external

avatar
r*g
5
intuitively true, could you plz give a more rigorous proof?

【在 l*****8 的大作中提到】
: 不存在,因为在one pass的过程中丢失了前面的所有信息,所以对于数组中的任意一个
: 数字都不能确定前面是否有能配对的数字。
:
: pair
: external

avatar
l*8
6
I think it's clear enough and logically true. The point here is that you
cannot keep any previous information. Any previous numbers become unknown.

【在 r*g 的大作中提到】
: intuitively true, could you plz give a more rigorous proof?
avatar
r*g
7
Thanks, I read some materials and give a proof here.
But it's pretty complicated. Your idea is nice.
Hope it helps.

【在 l*****8 的大作中提到】
: I think it's clear enough and logically true. The point here is that you
: cannot keep any previous information. Any previous numbers become unknown.

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。