## Interview Question

Country: United States

Comment hidden because of low score. Click to expand.
1
of 1 vote

Activity Selection Problem

Classic greedy algorithm....

Comment hidden because of low score. Click to expand.
-1

Eh?

First, the problem is quite vague.

Second, the greedy algorithm for activity selection applies when there is only one processor. For more processor, I believe it is NP-Hard.

Comment hidden because of low score. Click to expand.
1
of 1 vote

sort the n meeting according to their end times
Keep assigning the 1...n meetings to the first of the meeting room 1..m which is free

Comment hidden because of low score. Click to expand.
0

Who said you were given start times?
Can you prove your strategy works?
What does "works" mean in this question?
How does one define optimal for such a vague question?

Comment hidden because of low score. Click to expand.
0

meetings will have start and end times... This is the classic greedy problem - Inteval scheduling problem

Comment hidden because of low score. Click to expand.
0

can u prove that greedy works?

Comment hidden because of low score. Click to expand.
0

u are just memorizing things , you have to state reasoning that is wat careercup is for

Comment hidden because of low score. Click to expand.
0

Lets assume somethings...m==1, n==2 and all meetings start at the same time, with varying end times. In this case, sorting by end times => the shortest meeting gets the room first. The proposed algorithm seems like one based on the "Shortest Job Next" algorithm. In this algo, the advantage is that the average wait times are minimized. If we assume meeting times and durations are known, this algorithm seems to work in my opinion.

Comment hidden because of low score. Click to expand.
0
of 0 vote

is this binpacking?

Comment hidden because of low score. Click to expand.
0
of 0 vote

we can maintain m queues with n/m meetings in each queue. Use the FIFO to schedule the meeting. If one queue is empty we can reshedule the queue. This can be one of the solution. Ques never asked for optimal solution.

Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

### Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

### Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.