Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NEW ALGORITHM] : Maximal Rectangle (DP) #1589

Closed
2 tasks done
ananydev opened this issue Nov 2, 2024 · 5 comments
Closed
2 tasks done

[NEW ALGORITHM] : Maximal Rectangle (DP) #1589

ananydev opened this issue Nov 2, 2024 · 5 comments

Comments

@ananydev
Copy link
Contributor

ananydev commented Nov 2, 2024

Issue will be closed if:

  1. You mention more than one algorithm. You can create a separate issue for each algorithm once the current one is completed.
  2. You propose an algorithm that is already present or has been mentioned in a previous issue.
  3. You create a new issue without completing your previous issue.

Note: These actions will be taken seriously. Failure to follow the guidelines may result in the immediate closure of your issue.


Name: Maximal Rectangle (DP)

[NEW ALGORITHM]

About:

Propose a new algorithm to be added to the repository

Preprocess Heights: Instead of focusing on individual rows and building height stacks, calculate the cumulative "height" for every 1 in the matrix, row by row. This is similar to the traditional histogram approach, but here we maintain a cumulative sum array for each column as we iterate over each row. This helps us to keep track of vertical continuity of 1s.

Sliding Window Histogram Expansion:

For each row, consider it as the "base" of potential rectangles.
Use a sliding window to determine all possible rectangles within the current row’s "height array." Start with the smallest possible width (1) and expand the width while checking if it’s possible to extend the rectangle upwards.
Dynamic Width & Height Validation: While expanding the width, maintain the minimum height encountered in the sliding window (the limiting factor for height as the rectangle expands sideways).

For each rectangle width w being considered at row r, calculate the maximum possible area based on the minimal height in the window so far:
area

width
×
minHeight
area=width×minHeight
Track the maximum area encountered at each stage of expansion.
Update Maximum Rectangle: As each row is processed with the sliding window and width expansion, update the maximum rectangle area found.

Labels:

new algorithm, gssoc-ext, hacktoberfest, level1


Assignees:

  • Contributor in GSSoC-ext
  • Want to work on it
@ananydev
Copy link
Contributor Author

ananydev commented Nov 2, 2024

@pankaj-bind KINDLY ASSIGN ME THIS . I'LL START WORKING ON IT IMMEDIATELY

@ananydev
Copy link
Contributor Author

ananydev commented Nov 3, 2024

@pankaj-bind pls update !!

@ananydev
Copy link
Contributor Author

ananydev commented Nov 3, 2024

pls update

@ananydev
Copy link
Contributor Author

ananydev commented Nov 4, 2024

kindly update

@pankaj-bind
Copy link
Collaborator

assigned

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants