FastPrepUnion Area of Two Rectangles
Problems/Union Area of Two Rectangles

Union Area of Two Rectangles

DocuSign logoDocuSign● EasyFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report describes the well-known exercise of finding the area covered by two rectangles together. We chose a long return type so the area stays exact across the coordinate limits.

Two axis-aligned rectangles are described by their bottom-left and top-right corners: (ax1, ay1), (ax2, ay2) and (bx1, by1), (bx2, by2).

Return the total area covered by at least one rectangle.

Function

rectangleUnionArea(ax1: int, ay1: int, ax2: int, ay2: int, bx1: int, by1: int, bx2: int, by2: int) → long

Examples

Example 1

ax1 = -3ay1 = 0ax2 = 3ay2 = 4bx1 = 0by1 = -1bx2 = 9by2 = 2return = 45

The rectangle areas are 24 and 27, and their overlap area is 6, giving 45.

Example 2

ax1 = 0ay1 = 0ax2 = 2ay2 = 2bx1 = 2by1 = 0bx2 = 4by2 = 2return = 8

The rectangles touch at an edge but have zero overlap area.

Constraints

  • -10^9 <= ax1 < ax2 <= 10^9 and -10^9 <= ay1 < ay2 <= 10^9.
  • The same strict corner ordering holds for rectangle B.
  • The answer fits in a signed 64-bit integer.

More DocuSign Phone Screen questions

  • Symmetric Binary TreePHONE SCREEN · Seen Oct 2026
  • Execute Cursor-Based Text Editor OperationsPHONE SCREEN · Seen Sep 2026
  • Minimize Array Sum After K Halving OperationsPHONE SCREEN · Seen Sep 2026
  • Fizz and Buzz Words From 1 to nPHONE SCREEN · Seen Sep 2026
  • Two Positions That Add Up to a TargetPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Rain Kept Between WallsPHONE SCREEN · Seen Mar 2026
  • Exact Palindrome CheckPHONE SCREEN · ONSITE INTERVIEW · Seen Apr 2022
  • Reverse the Characters of a TextPHONE SCREEN · ONSITE INTERVIEW · Seen Apr 2022
  • Rebuild a Trip From Flight TicketsPHONE SCREEN · Seen Apr 2019
  • Find the Words for Each PrefixPHONE SCREEN · Seen Sep 2018

Similar questions at other companies

  • Range of a Third CorrelationTower Research Capital · PHONE SCREEN
  • Three Points in a Semicircle: Monte Carlo EstimateSquarepoint Capital · PHONE SCREENSquarepoint Capital interview questions
  • Angle Between Clock HandsJane Street · PHONE SCREENJane Street interview questions
  • Catching the Bus to the MovieSusquehanna International Group (SIG) · PHONE SCREENSusquehanna International Group (SIG) interview questions
  • Intersection of Two RectanglesFigma · PHONE SCREENFigma interview questions
  • Light Source Hits: Sample, Compare, and FitOpenAI · PHONE SCREENOpenAI interview questions
  • Max Points on a LineUber · PHONE SCREENUber interview questions
  • Count Axis-Aligned and Rotated SquaresGoogle · PHONE SCREENGoogle interview questions
  • Best-Fit Plane Normal from 3D PointsThe Voleon Group · PHONE SCREEN
  • Meeting of Points Moving Toward Initial SuccessorsThe Walt Disney Company · PHONE SCREENThe Walt Disney Company interview questions

DocuSign interview experiences

  • DocuSign SWE Intern Interviews: 27 Experiences (Part 2 of 2)
  • DocuSign SWE Intern OA Questions: 53 Experiences (Part 1 of 2)
All DocuSign interview questionsSee DocuSign hiring insights
Saved
class Solution {
    public long rectangleUnionArea(int ax1, int ay1, int ax2, int ay2, int bx1, int by1, int bx2, int by2) {
        // Write your code here.
    }
}
Checking account…