Amazon | SDE OA | New question - Thieves Combination
Anonymous User
1014

Thieves combinations Problem::

Theft occurred in the community where Little A is located. Now, people have determined that the thief comes from their own community, and there are exactly 2 people.

There are n people in the community, and everyone has a certain impression of the others around, so everyone decided to vote for the most suspicious person.

Each person has two votes to vote for people they think are suspicious. The community property believes that at least one of the two people voted by one person is a real thief, and that this person has a keen sense of smell.

The community property wants to know how many possible combinations of thieves, so that the whole community has at least K people with a keen sense of smell?

Enter description
The first line of input contains two integers n and K, which are the number of people in the community. The meaning of K is shown in the title.

In the next n lines, each line has two integers ai and bi, representing two votes cast by the i-th person. Data guarantees that for any i, ai and bi are not the same, but one person may vote for himself.

1≤K≤n≤100000

Output description
Output an integer, representing how many possible thieves combinations.

Sample input
4 4
1 2
2 3
1 4
1 3
Sample output
2

Explanation
There are two kinds of [1,2][1,3]

Java Code:

public int thievesCombination(int[][] votes, int k){

}

Appreciate any suggestions on solving. Thank you

Comments (4)