算法找到对数字的整数数组whoes总和相等 [英] Algorithm to find the pair of numbers in an integer array whoes sum are equal

查看:84
本文介绍了算法找到对数字的整数数组whoes总和相等的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

算法找到对数字的整数数组whoes总和是相等的。 前{1 2 3 4 6}

Algorithm to find the pair of numbers in an integer array whoes sum are equal. ex {1 2 3 4 6}

此处{3 2} {4 1}应的输出,因为总和是3 + 2 = 5,4 + 1 = 5。

here{3 2} { 4 1} should be the output, because the sum is 3+2=5, 4+1=5.

在这里,主要的是复杂SHLD是为O(n)。请帮我,如果我们发现这个任何的解决方案?

Here the main thing is the complexity shld be O(n). Please help me if we find any solutions for this?

推荐答案

你确定这个问题是可以解决的,在所有的O(N)?

Are you sure that the problem is solvable at all in O(n)?

想象的情况下,当输入序列是​​仅有{0,0,0,0,0,0,...,0}。这里每两个双满足该条件。刚刚上市的所有对已至少为O(n ^ 2)。

Imagine the case when the input sequence is just {0, 0, 0, 0, 0, 0, ..., 0}. Here every two pairs satisfy the condition. Just listing all the pairs is already at least O(n^2).

这篇关于算法找到对数字的整数数组whoes总和相等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆