Блог пользователя chillua98

Автор chillua98, история, 3 недели назад, По-английски

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?

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится