解释实施例的给K个最大数量的号码从各N个给定集合? [英] Explain example of giving K-th largest number of numbers from each of N given sets?

查看:82
本文介绍了解释实施例的给K个最大数量的号码从各N个给定集合?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天,我试图解决一个 Facebook的编程挑战赛。我得到的挑战是'栏问题,可以找到这里。的挑战过程中我的问题是要明白,他们所提供的第一个例子。

问题可以总结如下:

  <磷>氮朋友都在玩游戏。他们每个人都有自己的前面号码列表

     

每个N个朋友选择一个号码,从他的名单,并上报给游戏管理员。然后游戏管理员排序报告的数字和呐喊第K个数量最多。

     

您想知道算所有可能的数字,游戏管理员可以留言。

要这一点我认为我懂得了这个问题,但那么他们presented下面的例子:

  

在给定的,对于第一测试用例,N = 3且K = 3清单的第一人的样品的例子是{2 5 3},{8 1 6}的第二和{7 4 9}的三分之一。在这种情况下,在所有的数字{4,5,6,7,8,9}有机会成为第三大选定数目

所以我的问题是:

哪有7,8和9中选择的第三大多少?

在我看来,只有数字{1,2,3,4,5}可以是第三大数字,但也许我误解的算法。

解决方案

我想你是对的,他们排序的数字错误的方式。所提出的例子回答貌似正确的回应,如果你想获得第三个最小的,而不是第三大。也就是说,它们的排序从最小到最大,你得到的三分之一。这是在这个问题不是说(但英语不是我的第一语言,所以我可能搞错了)。

Today I tried to solve a Facebook Programming Challenge. The challenge that I got was the 'Bar problem', which can be found here. My problem during the course of the challenge was to understand the first example that they provided.

The problem can be summarized as follows:

N friends are playing a game. Each of them has a list of numbers in front of himself.

Each of N friends chooses a number from his list and reports it to the game administrator. Then the game administrator sorts the reported numbers and shouts the K-th largest number.

You want to know the count all possible numbers that the game administrator can shout.

To that point I thought that I had understood the problem but then they presented the following example:

In the sample example given, for the first testcase N = 3 and K = 3. List for the first person is {2 5 3}, {8 1 6} for second and {7 4 9} for the third. In this case all the numbers in {4, 5, 6, 7, 8, 9} have a chance to be the third biggest selected number.

So my question is:

How can 7, 8 and 9 be the third biggest selected number?

In my opinion only the numbers {1, 2, 3, 4, 5} can be third biggest number but maybe I misunderstood the algorithm.

解决方案

I think you are right, they sorted the numbers the wrong way. The proposed example reply looks like the correct reply if you want to get the third smallest, not the third greatest. That is, sorting them from smallest to greatest, you get the third. This is not what stated in the question (but English is not my first language so I may get it wrong).

这篇关于解释实施例的给K个最大数量的号码从各N个给定集合?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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