chillua98's blog

By chillua98, history, 3 weeks ago, In English

There was a question I came across in an Online Assessment recently and I was not able to solve it. It goes as follows:-

There are n children in a classroom and the teacher wants to arrange them in a circle, such that the max height between any 2 students is MINIMIZED.

For example:-

N=7 Students: 4 1 3 2 1 2 3

The minimum value of max height diff is 1, if we arrange it as follows:

2 3 4 3 2 1 1

(Just a reminder that the height difference between the first student and the last student is also considered as they are in a circle)

I thought it was involving Binary Search but couldn't come up with a helper function. Could someone please help me out?

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it