Skip to content
New issue

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

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

Already on GitHub? # to your account

[2428] Hour Glass Sum #48

Merged

Conversation

chhavibansal
Copy link
Contributor

@chhavibansal chhavibansal commented Oct 2, 2022

Solution for Leetcode Problem: 2428
https://leetcode.com/problems/maximum-sum-of-an-hourglass/description/
Submitting as part of hackoctober Fest. Please approve if you find it correct, it is accepted solution on leetcode #49

Copy link
Owner

@ignacio-chiazzo ignacio-chiazzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey! thanks for contributing! 🙌

The solution looks good to me. I'm curious if we could reduce the N**2 computation time.

Could you add an entry in the changelog to the problem? and write a file test with a few examples? You can follow this PR #39. After that, we can merge the PR.

2428. Maximum Sum of an Hourglass

You are given an m x n integer matrix grid.
We define an hourglass as a part of the matrix with the following form:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add an example of the matrix here? It could be with text if the original problem use images.


Note that an hourglass cannot be rotated and must be entirely contained within the matrix.
Input: grid = [[6,2,1,3],[4,2,1,5],[9,2,8,7],[4,1,2,9]]
Output: 30
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could use an explanation of why it's 30.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update the code @ignacio-chiazzo Added as per the format in PR #39.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please review again?

@chhavibansal
Copy link
Contributor Author

N**2 computation time
For the computation time, this is the best computation time for this problem, verified with Leetcode discuss panel as well.

Copy link
Owner

@ignacio-chiazzo ignacio-chiazzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! It looks good to me.

I left a comment on the readme, but otherwise, it looks great. #49

README.md Outdated
@@ -79,7 +79,7 @@ To run a specific problem in your console run `node <problem_file_path>` (e.g.
| [Permutations With Duplicates ](/LeetcodeProblems/Algorithms/Permutations_With_Duplicates.js) | | |
| [Deletion Distance](/LeetcodeProblems/Algorithms/Deletion_Distance.js) | | |
| [Award Budget Cuts](/LeetcodeProblems/Algorithms/Award_Budget_Cuts.js) | | |

| [Maximum Sum of an Hourglass](/LeetcodeProblems/Algorithms/Maximise_Hour_Glass_Sum.js) | Medium | https://leetcode.com/problems/maximum-sum-of-an-hourglass/ |
Copy link
Owner

@ignacio-chiazzo ignacio-chiazzo Oct 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: The problems are sorted by complexity, could you move this problem to the medium section? Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the ordering @ignacio-chiazzo

@ignacio-chiazzo
Copy link
Owner

Thank you!

@ignacio-chiazzo ignacio-chiazzo merged commit 675f694 into ignacio-chiazzo:master Oct 2, 2022
@chhavibansal
Copy link
Contributor Author

Hi @ignacio-chiazzo your repo has the tag hacktoberfest-accepted but the hackoctober official page says otherwise[ that this repo is not registered]. Can you tell me if its accepted or not?

@ignacio-chiazzo
Copy link
Owner

Uf! I just realized that the tag was invalid. The tag is hacktoberfest-accepted

It should be fixed now. Let me know if you don't receive the count of the PR.

@chhavibansal
Copy link
Contributor Author

Yeah ! getting the following msg
AWESOME! YOUR PR/MR HAS BEEN ACCEPTED BY A MAINTAINER AND IS NOW IN A SEVEN-DAY REVIEW PERIOD. NO ACTION IS NEEDED, AND ASSUMING YOUR PR/MR IS STILL ACCEPTED AFTER SEVEN DAYS IT WILL COUNT TOWARDS YOUR PARTICIPATION IN HACKTOBERFEST!

thanks

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

Successfully merging this pull request may close these issues.

2 participants