Erect the Fence
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
You are given the positions of trees in a garden as trees[i] = [x, y]. A fence of minimum total length must be built so that every tree lies inside it or on it; that fence is the boundary of the convex hull of the trees.
Return the coordinates of every tree that lies **on the fence**. That includes the corner trees and also any tree lying on a straight fence segment between two corners.
Trees may be returned in **any order**. All positions are distinct. If all trees are on one line, every tree is on the fence.
Examples
Constraints
- 1 <= trees.length <= 3000
- trees[i].length == 2
- 0 <= x, y <= 100
- All positions are unique
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.