Valid Square
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 four points in the plane, p1, p2, p3, and p4, each as [x, y] with integer coordinates. The points are listed in no particular order.
Return true if the four points are the corners of a square with **positive** side length, and false otherwise. The square does not have to be aligned with the axes.
If two or more of the points coincide, the answer is false.
Examples
Constraints
- `p1.length == p2.length == p3.length == p4.length == 2`
- `-10^4 <= x, y <= 10^4`
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.