Dsa
Math
Hard
Count Distinct Squares
You are provided with a list of N integer coordinates that represent the bottom-left corners of squares with a side length of 1. Your task is to count how many distinct unit squares are covered by at least one of the squares. The input begins with an integer N followed by N pairs of integers representing the coordinates. Output the total count of distinct unit squares covered.
Example:
Input:
5
0 0
0 1
1 0
1 1
1 2
Output:
6
Key concepts
geometrycombinatoricsset theory
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now