Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

The problem is as follows, There is a restaurant which has N number of chairs each chair has a unique number written on it so the array of chairs is like [1,2,....N-1,N] , there are G number of groups who want to sit in the restaurant each group can have any number of persons (from 1 to N ) who have a certain preference for chair number they want to sit at now , only one person can sit on the chair obviously ,now i have to maximize the number of groups which can sit in the restaurant . what is the best way/algorithm to do this?

For example if N (number of chairs ) is 7 and Groups (G) who want to sit are 4 and preference for chairs are as follows group

1 -> 3,7

2 -> 5,6

3 -> 3,4

4 -> 1,2

So we can represent the data in the form of an array enter image description here

so the maximum number of groups that sit are 3 (group 2,3,4) the required answer .

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.