← Purestorage Interview Insights

Purestorage·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
Jun 2026

Summary

Pure Storage coding interview for a software engineer role, focused entirely on a geometry problem about detecting and counting squares from point coordinates. The problem had multiple parts with increasing complexity, which I did not fully anticipate going in.

Questions Asked (2)

Q1

Given exactly 4 points on a 2D plane, determine whether they form a valid (possibly rotated) square.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

Part A felt manageable.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying constraints (integer vs floating-point coordinates, exact vs approximate equality) and then propose a robust method: compute all pairwise squared distances, sort them, and check that the four smallest are equal and positive, the two largest are equal, and the largest equals twice the smallest. Alternatively, use geometric properties like checking diagonals and sides after sorting points by angle or using a set of distances.

Pro tip: Mention that using squared distances avoids floating-point square roots and precision issues, and always discuss how to handle floating-point comparisons with an epsilon.

1. Clarify requirements and constraints

Ask about input format (integer vs floating-point), tolerance for floating-point errors, and whether the square can be degenerate (zero area).

2. Choose a robust algorithm

Decide between distance-based method (compute all 6 pairwise squared distances) or geometric method (sort points, check sides and diagonals).

3. Implement the check

For distance-based: sort distances, verify d[0]=d[1]=d[2]=d[3]>0, d[4]=d[5], and d[4]=2*d[0]. For geometric: compute centroid, sort points by angle, then check equal sides and right angles.

4. Handle edge cases and precision

Use epsilon for floating-point comparisons; ensure no duplicate points; consider collinear points that might falsely pass if not checked properly.

5. Analyze complexity and trade-offs

Discuss time complexity (O(1) since only 4 points) and space complexity (O(1)), and compare the simplicity vs robustness of each approach.

Key Points to Mention

  • Use squared distances to avoid square roots and floating-point precision issues.
  • Sort the six pairwise squared distances and check the pattern: four equal small distances and two equal large distances, with large = 2 * small.
  • Handle floating-point comparisons with an epsilon tolerance.
  • Ensure the square is non-degenerate (side length > 0).
  • Consider alternative geometric approach: sort points by angle around centroid and check side lengths and right angles.
  • Discuss time and space complexity: O(1) for fixed number of points.

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

Q2

Given N points on a 2D plane, count how many distinct squares can be formed using 4 of those points as vertices. Walk through a brute-force O(n^4) approach, then optimize to O(n^3), then to O(n^2).

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

This is where things got rough.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clearly defining the problem and the brute-force O(n^4) solution, then systematically optimize by reducing redundant checks. For O(n^3), fix two points as a diagonal and check for the other two; for O(n^2), use a hash set to store points and for each pair check if they can be a side or diagonal of a square, counting each square once.

Pro tip: When optimizing, emphasize the trade-off between time and space, and discuss how to avoid double-counting squares by enforcing an ordering (e.g., only consider pairs where p1 < p2).

1. Clarify and Define

Restate the problem, confirm input format, and discuss edge cases (e.g., duplicate points, collinear points).

2. Brute Force O(n^4)

Explain checking all quadruples of points and verifying if they form a square using distance and angle checks.

3. Optimize to O(n^3)

Fix two points as a diagonal, compute the other two vertices, and check if they exist in the set; count each square once by ordering.

4. Optimize to O(n^2)

For each pair of points, treat them as a side or diagonal, compute the other vertices, and check existence in a hash set; use canonical ordering to avoid duplicates.

5. Analyze and Conclude

Compare time/space complexities, discuss trade-offs, and mention potential pitfalls like floating-point precision.

Key Points to Mention

  • Geometric properties of a square: equal sides, right angles, diagonals equal and perpendicular bisectors.
  • Using a hash set for O(1) point lookup to achieve O(n^2) time.
  • Avoiding double-counting by enforcing a consistent ordering of vertices (e.g., only count when p1 < p2).
  • Handling duplicate points and collinear points as edge cases.
  • Time and space complexity analysis for each approach.
  • Potential floating-point precision issues when computing coordinates and how to mitigate (e.g., using integer arithmetic if points are integers).

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