Points on Square Perimeter

Company: London Stock Exchange Group(LSEG)_2Nov

Difficulty: medium

Problem Statement

Points on Square Perimeter Problem Description You are given N points in the plane. The i -th point is (X[i], Y[i]) . No two points are the same. Decide whether there is a square whose sides are parallel to the coordinate axes such that every given point lies on that square's perimeter. A point lies on the perimeter if it is on one of the four sides, endpoints included; a point strictly inside the square does not count, and neither does a point outside it. The square may be placed anywhere and may have any side length, including zero. Function Description Complete the solution function. It takes the following parameters: N : INTEGER, the number of points. X : INTEGER ARRAY of size N , the x coordinates. Y : INTEGER ARRAY of size N , the y coordinates. The function must return the STRING "true" if such a square exists and "false" otherwise. Input Format The first line contains the integer N . The second line contains N space-separated integers, the array X . The third line contains N sp