Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
You don't need a boolean[] as the input. The only concern is the count of urinals.
To ensure that no two persons are standing next to each other, people can simply be placed after leaving one vacant space.
The algorithm you implemented is to ensure that people stand at the farthest distance possible. A simple logic to get to the next to next is enough.
I'm saying the optimality of both the approaches is same. In both the approaches, a simple formula is used to move to the next space.
In any case, if the number of people is greater than ceil (urinalsCount / 2), it will be a cursed situation.