算法找到对数字的整数数组whoes总和相等

编程入门 行业动态 更新时间:2024-10-15 06:16:21
本文介绍了算法找到对数字的整数数组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总和相等

本文发布于:2023-11-30 00:17:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1648085.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:整数   数组   总和   算法   数字

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!