Amazon Interview Question
Anonymous User
551

/*

We are building part of the algorithm for creating a rectangular game board for a game.

We will be given as input, a number n, representing the minimum number of spaces that the board must contain.

Our task is to find the board dimensions w and h such that:

1. The board has at least n spaces

2. The board has no more than n + 2 spaces

3. The shape of the board is as close to square as possible

4. w >= h

Examples:

n = 16 -> w=4, h=4

n = 15 -> w=4, h=4

n = 18 -> w=5, h=4

*/

Comments (2)