← Pure Storage Interview Insights

Pure Storage·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
Jun 2026

Summary

Interviewed for a software engineer role at Pure Storage and got a geometry problem I did not see coming. One coding round, fairly algorithmic, nothing behavioral from what I remember.

Questions Asked (1)

Q1

Given four 2D points, write a function to determine whether they form a valid square (axis-aligned or rotated).

Algorithms & Data Structures
Author's notes

My first instinct was to check slopes and distances separately and I immediately started going down a path involving floating point comparisons which felt wrong even as I was saying it.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify that the points are distinct and form a square if all sides are equal and diagonals are equal and longer than sides. Compute all six pairwise squared distances, sort them, and check that the first four are equal and positive, and the last two are equal and exactly twice the side squared. Alternatively, use a geometric property like checking center and vertices, but the distance method is simpler and robust.

Pro tip: Mention that using squared distances avoids floating-point precision issues, and explicitly handle duplicate points or degenerate cases (e.g., all points collinear) by ensuring the side length is greater than zero.

1. Clarify assumptions and edge cases

Confirm that the four points are distinct and that a valid square must have non-zero area. Discuss how to handle duplicate points or collinear points.

2. Choose a distance-based approach

Compute all six pairwise squared distances between the four points. This avoids square roots and floating-point comparisons.

3. Sort and validate distances

Sort the six distances. For a square, the four smallest must be equal (side length squared) and positive, and the two largest must be equal and exactly twice the side squared (diagonal squared).

4. Implement and test

Write the function, then test with axis-aligned, rotated, and invalid cases (e.g., rectangle, rhombus, collinear points).

Key Points to Mention

  • Use squared distances to avoid floating-point precision issues.
  • A square has four equal sides and two equal diagonals that are longer than the sides.
  • The diagonal squared is exactly twice the side squared (Pythagorean theorem).
  • Sorting the six distances simplifies the check: first four equal, last two equal and double.
  • Handle edge cases: duplicate points, zero-area (all points collinear), and non-square rectangles/rhombuses.
  • Time complexity is O(1) since there are only six distances; space complexity O(1).

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.