← Practice problem bank

Jan 23, 2026

The Coordinate Conundrum

Daily Challenge Archive · Open

easyarrays

100 pts · 10000 ms · 128 MB · Practice only

Problem

As a visionary city planner, you are tasked with designing a new rectangular park that will enclose a collection of scattered landmarks on a city map, represented as points on a 2D plane. The park's boundaries must align with the x and y axes, making your job to determine the minimal dimensions required. To achieve this, you'll need to identify the smallest and largest x and y coordinates among all landmarks, as these will determine the park's borders. Here's a step-by-step guide: 1. List all the x and y coordinates from the points provided. 2. Determine the minimum and maximum values for both the x and y axes. 3. Use these values to define the rectangle's corners: (min_x, min_y), (max_x, min_y), (max_x, max_y), and (min_x, max_y). 4. Calculate the width and height of the rectangle using these coordinates. Consider a scenario where your points are (1,3), (4,5), (2,8), and (6,3). The smallest rectangle would have corners at (1,3) and (6,8), with a width of 5 and a height of 5.

Hints
Think about iterating through the list of points to find the min and max values efficiently. Consider using data structures like arrays or lists to store your coordinates. Be mindful of edge cases, such as when all points lie on a single line, or when there's only one point. Remember, the goal is to create the smallest possible rectangle, so keep your calculations precise!

Input format

The first line contains an integer n (1 <= n <= 100), the number of points. Each of the next n lines contains two integers x and y, representing the coordinates of a point (-1000 <= x, y <= 1000).

Output format

Output a single line with four integers: x_min, y_min, x_max, y_max, which are the coordinates of the bottom-left and top-right corners of the rectangle.

Constraints

1 <= n <= 100, -1000 <= x, y <= 1000

Sample input

4
1 1
1 3
3 1
3 3

Sample output

1 1 3 3

Sign in to submit solutions

Run your code against all test cases and get instant feedback.

Sign in