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
.
For example:
f = [-2, 1, 0] d = 8
Suitable points are [-1, 0, 1]
.
Explanation:
- Location:
-1
(2 * |-1 - (-2)|) + (2 * |-1 - (1)|) + (2 * |-1 - (0)|) = 8
- Location:
0
(2 * |0 - (-2)|) + (2 * |0 - (1)|) + (2 * |0 - (0)|) = 6
- Location:
1
(2 * |1 - (-2)|) + (2 * |1 - (1)|) + (2 * |1 - (0)|) = 8
Not Suitable:
- Location:
-3
(2 * |-3 - (-2)|) + (2 * |-3 - (1)|) + (2 * |-3 - (0)|) = 16
Candidate's Approach
No approach provided.
Interviewer's Feedback
No feedback provided.