Tap here to switch tabs
Problem
Submissions

Problem: Find the Largest Area of Square Inside Two Rectangles

Try to solve the Find the Largest Area of Square Inside Two Rectangles problem.

Statement

You are given two 2extD2 ext{D} integer arrays bottomLeft and topRight, each of length n, representing n axis aligned rectangles on a 2extD2 ext{D} Cartesian plane.

The iextthi^{ ext{th}} rectangle is defined by its bottom left coordinate bottomLeft[i] and its top right coordinate topRight[i].

Return the maximum possible area of a square that can fit completely inside the intersecting region of at least 22 rectangles. If no two rectangles intersect, return 00.

Constraints:

  • n ==== bottomLeft.length ==== topRight.length

  • 2≤2 \leq n ≤103\leq 10^3

  • bottomLeft[i].length ==== topRight[i].length ==2== 2

  • 1≤1 \leq bottomLeft[i][0], bottomLeft[i][1] ≤107\leq 10^7

  • 1≤1 \leq topRight[i][0], topRight[i][1] ≤107\leq 10^7

  • bottomLeft[i][0] << topRight[i][0]

  • bottomLeft[i][1] << topRight[i][1]

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Find the Largest Area of Square Inside Two Rectangles

Try to solve the Find the Largest Area of Square Inside Two Rectangles problem.

Statement

You are given two 2extD2 ext{D} integer arrays bottomLeft and topRight, each of length n, representing n axis aligned rectangles on a 2extD2 ext{D} Cartesian plane.

The iextthi^{ ext{th}} rectangle is defined by its bottom left coordinate bottomLeft[i] and its top right coordinate topRight[i].

Return the maximum possible area of a square that can fit completely inside the intersecting region of at least 22 rectangles. If no two rectangles intersect, return 00.

Constraints:

  • n ==== bottomLeft.length ==== topRight.length

  • 2≤2 \leq n ≤103\leq 10^3

  • bottomLeft[i].length ==== topRight[i].length ==2== 2

  • 1≤1 \leq bottomLeft[i][0], bottomLeft[i][1] ≤107\leq 10^7

  • 1≤1 \leq topRight[i][0], topRight[i][1] ≤107\leq 10^7

  • bottomLeft[i][0] << topRight[i][0]

  • bottomLeft[i][1] << topRight[i][1]