Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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|cite|improve this question

Your Answer


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

Browse other questions tagged or ask your own question.