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

1046. Last Stone Weight #6

Merged
merged 2 commits into from
Jul 12, 2024
Merged

1046. Last Stone Weight #6

merged 2 commits into from
Jul 12, 2024

Conversation

stada526
Copy link
Owner

@stada526 stada526 commented Jul 12, 2024

Problem Link

https://leetcode.com/problems/last-stone-weight/description/

Solution

In this problem, we need to repeatedly take the two largest numbers from an array of integers stones, and then push a new number based on the two numbers.
Therefore, we use a max heap to efficiently pop the largest number.
This way, popping the largest number can operate in O(1), and pushing a new number can operate in O(log n).

@stada526 stada526 merged commit 48d5fb5 into main Jul 12, 2024
1 check passed
@stada526 stada526 deleted the f/1046 branch July 12, 2024 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant