算法找到在不断的空间和O(n)时间重复项

编程入门 行业动态 更新时间:2024-10-16 02:24:09
本文介绍了算法找到在不断的空间和O(n)时间重复项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

给定N整数的阵列使得只有一个整数是重复的。查找在O(n)的时间和空间,不断重复的整数。有没有范围的整数的值或N值

Given an array of N integer such that only one integer is repeated. Find the repeated integer in O(n) time and constant space. There is no range for the value of integers or the value of N

例如给予6的整数数组为23 45 67 87 23 47。答案是23 (我希望这包括含糊不清的部分)

For example given an array of 6 integers as 23 45 67 87 23 47. The answer is 23 (I hope this covers ambiguous and vague part)

我在网上搜索,但未能找到其整数范围为不固定的任何问题。 此外这里是回答了类似的问题,以我的一个例子,但在这里,他创建了在C ++中的最高整数值的哈希表,但CPP不允许这样来创建2 ^ 64元素的数组(64位计算机上)。

I searched on the net but was unable to find any such question in which range of integers was not fixed. Also here is an example that answers a similar question to mine but here he created a hash table with the highest integer value in C++.But the cpp does not allow such to create an array with 2^64 element(on a 64-bit computer).

我很抱歉,我没有提到它前阵是不可改变的。

I am sorry I didn't mention it before the array is immutable

推荐答案

如果阵列没有排序,你只能做它 O(nlogn)。

If the array isn't sorted, you can only do it in O(nlogn).

一些方法可以发现这里 。

Some approaches can be found here.

更多推荐

算法找到在不断的空间和O(n)时间重复项

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

发布评论

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

>www.elefans.com

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