Panda Guru LogoPanda
Guru

Amazon | OA | Maximum Suitable Location

Round 1

Questions: Given factory location array f (values are in a number line) and a distance d. Find all the suitable locations that have a distance of no more than d.

image

For example:

f = [-2, 1, 0] d = 8

Suitable points are [-1, 0, 1].

Explanation:

(2 * |-1 - (-2)|) + (2 * |-1 - (1)|) + (2 * |-1 - (0)|) = 8
(2 * |0 - (-2)|) + (2 * |0 - (1)|) + (2 * |0 - (0)|) = 6
(2 * |1 - (-2)|) + (2 * |1 - (1)|) + (2 * |1 - (0)|) = 8

Not Suitable:

(2 * |-3 - (-2)|) + (2 * |-3 - (1)|) + (2 * |-3 - (0)|) = 16
Candidate's Approach

No approach provided.

Interviewer's Feedback

No feedback provided.