找到独特的常见的元素,从3阵列 [英] Find unique common element from 3 arrays

查看:118
本文介绍了找到独特的常见的元素,从3阵列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

原始问题:
我有每片含200个硬币,因为只有一个谁已经从所有三箱的调用,因此没有在具有相同的指纹,所有的硬币休息有不同的指纹,每个箱子一个硬币的人3盒。你必须找到其中包含所有的3盒相同的指纹硬币。这样我们就可以找到谁已经从所有3盒作出呼叫的人的指纹。

Original Problem:
I have 3 boxes each containing 200 coins, given that there is only one person who has made calls from all of the three boxes and thus there is one coin in each box which has same fingerprints and rest of all coins have different fingerprints. You have to find the coin which contains same fingerprint from all of the 3 boxes. So that we can find the fingerprint of the person who has made call from all of the 3 boxes.

转换问题:
你有一个包含每个200整数3阵列。鉴于有且只有一个共同的元素在这些3阵列。找到共同的元素。
请考虑解决本作除了微不足道的O(1)空间为O(n ^ 3)的时间。

Converted problem:
You have 3 arrays containing 200 integers each. Given that there is one and only one common element in these 3 arrays. Find the common element.
Please consider solving this for other than trivial O(1) space and O(n^3) time.

推荐答案

在Pelkonen的回答有些改进:
从OP转换的问题:

Some improvement in Pelkonen's answer:
From converted problem in OP:

既然有一个在这3个阵列只有一个共同的元素。

我们只需要2个数组排序,找到共同的元素。

We need to sort only 2 arrays and find common element.

这篇关于找到独特的常见的元素,从3阵列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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