FastPrepCheck Four Points Form a Square
Problems/Check Four Points Form a Square

Check Four Points Form a Square

Expedia logoExpedia● MediumNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The task of checking whether four points make a square, and the first example, match the report at about 98%. We added limits on the coordinates.

Return whether the four supplied points are the vertices of a square with positive area. The points may appear in any order.

Repeated points cannot form a square. A square may be rotated; its sides do not need to be parallel to the coordinate axes.

Function

validSquare(points: int[][]) → boolean

Examples

Example 1

points = [[1,0],[0,1],[2,1],[1,2]]return = true

The four squared side lengths are 2, and the two squared diagonal lengths are 4.

Example 2

points = [[0,0],[2,0],[2,1],[0,1]]return = false

This is a rectangle with side lengths 2 and 1, so its sides are not all equal.

Constraints

  • points.length == 4.
  • points[i].length == 2.
  • -10000 <= points[i][j] <= 10000.

More Expedia Onsite Interview questions

  • Scramble StringONSITE INTERVIEW · Seen Sep 2026
  • Smallest Sufficient TeamONSITE INTERVIEW · Seen Sep 2026
  • Check Anagram Pairs Index by IndexONSITE INTERVIEW · Seen Oct 2025
  • Fresh Oranges Left After Rotting StopsONSITE INTERVIEW · Seen Oct 2025
  • Longest Increasing SubsequenceONSITE INTERVIEW · Seen Oct 2025
  • Lowest Common Ancestor with Repeated and Missing ValuesONSITE INTERVIEW · Seen Oct 2025
  • Shortest Substring with Exactly K OnesONSITE INTERVIEW · Seen Oct 2025
  • Middle Element of a Linked ListONSITE INTERVIEW · Seen Nov 2024
  • Minimum in a Rotated Sorted ArrayONSITE INTERVIEW · Seen Sep 2024
  • Mirror Image Binary TreesONSITE INTERVIEW · Seen Sep 2024

Similar questions at other companies

  • Optimal Central WarehouseGoogle · ONSITE INTERVIEWGoogle interview questions
  • K Closest Points to a Query PointUber · ONSITE INTERVIEWUber interview questions
  • K Closest Points to a TargetAsana · ONSITE INTERVIEW
  • Locate Vehicles with Square QueriesApplied Intuition · PHONE SCREENApplied Intuition interview questions
  • Request Routing SystemStripe · OAStripe interview questions
  • Painting Arcs to Nearest Neighbors on a CircleSusquehanna International Group (SIG) · PHONE SCREENSusquehanna International Group (SIG) interview questions
  • Minimum Weighted Manhattan Travel CostConcentric AI · OAConcentric AI interview questions
  • HTTP Request RedirectionAmazon · OA
  • The k Points Nearest the OriginAdobe · PHONE SCREENAdobe interview questions
  • Closest Random Points (Also for Core/Database Engineering)Snowflake · OASnowflake interview questions

Interview reports that mention this question

  • Expedia New Grad SDE Earlier Loops: 5 Experiences (Part 2 of 3)

Expedia interview experiences

  • Expedia Intern Final Round in 2021: 28 Experiences (Part 4 of 6)
  • Expedia Intern Finals Before 2020: 14 Experiences (Part 6 of 6)
  • Expedia Intern Final Round in 2020: 24 Experiences (Part 5 of 6)
  • Expedia Intern Final Round in 2022: 15 Experiences (Part 3 of 6)
  • Expedia Intern Final Round in 2023: 17 Experiences (Part 2 of 6)
All Expedia interview questionsSee Expedia hiring insights
Saved
class Solution {
    public boolean validSquare(int[][] points) {
        // Write your code here.
    }

}
Checking account…