Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3482730
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:35:34+00:00 2026-05-18T10:35:34+00:00

I have a rectangular plane of integer dimension. Inside of this plane I have

  • 0

I have a rectangular plane of integer dimension. Inside of this plane I have a set of non-intersecting rectangles (of integer dimension and at integer coordinates).

My question is how can I efficiently find the inverse of this set; that is the portions of the plane which are not contained in a sub-rectangle. Naturally, this collection of points forms a set of rectangles — and it is these that I am interested in.

My current, naive, solution uses a boolean matrix (the size of the plane) and works by setting a point i,j to 0 if it is contained within a sub-rectangle and 1 otherwise. Then I iterate through each element of the matrix and if it is 1 (free) attempt to ‘grow’ a rectangle outwards from the point. Uniqueness is not a concern (any suitable set of rectangles is fine).

Are there any algorithms which can solve such a problem more effectively? (I.e, without needing to resort to a boolean matrix.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T10:35:35+00:00Added an answer on May 18, 2026 at 10:35 am

    Yes, it’s fairly straightforward. I’ve answered an almost identical question on SO before, but haven’t been able to find it yet.

    Anyway, essentially you can do this:

    • start with an output list containing a single output rect equal to the area of interest (some arbitrary bounding box which defines the area of interest and contains all the input rects)
    • for each input rect
      • if the input rect intersects any of the rects in the output list
        • delete the old output rect and generate up to four new output
          rects which represent the difference between the intersection
          and the original output rect

    Optional final step: iterate through the output list looking for pairs of rects which can be merged to a single rect (i.e. pairs of rects which share a common edge can be combined into a single rect).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have an Action delegate and trying to use the ternary operator inside of it
I have a live wallpaper that uses vibrate permission. When the slide screen that
I have a simple Activity and I would like to have the a rounded
I'm just going to throw this out here to get some feedback on it,
Have the following scenario. I have a few form, which essentially have a few
have anyone found a substitution for RJS in Ruby on Rails for play? P.S.
have different files with same name, in different directories. In these files there are
Have a flash player that pops out into a separate popup browser window. And
Have String str May 23 2011 12:20:00, want to convert it to date such
Need something simulat jcrop plucgin (link to example is here: http://publikz.com/one-more-task-rounded-selection-in-jquery/ ) but with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.