filmov
tv
Last Stone Weight (LeetCode Day 12 Question) | Programming Tutorials

Показать описание
Given a collection of stones, each stone has a positive integer weight. Each turn, we choose the two heaviest stones and smash them together.
Suppose the stones have weights x and y with x is less than equal to y. The result of this smash is:
If x == y, both stones are totally destroyed;
If x != y, the stone of weight x is totally destroyed,
and the stone of weight y has new weight y-x.
At the end, there is at most 1 stone left.
Return the weight of this stone (or 0 if there are no stones left.)
Input: {2, 7, 4, 1, 8, 1}
Output: 1
Explanation:
We combine 7 and 8 to get 1 so the array converts to {2, 4, 1, 1, 1} then,
we combine 2 and 4 to get 2 so the array converts to {2, 1, 1, 1} then,
we combine 2 and 1 to get 1 so the array converts to {1, 1, 1} then,
we combine 1 and 1 to get 0 so the array converts to {1} then that's the value of last stone.
This problem is the day 12 challenge of LeetCode 30 day challenge.
Last Stone Weight - Priority Queue - Leetcode 1046 - Python
Last Stone Weight (LeetCode Day 12 Question) | Programming Tutorials
LeetCode Day 12 - Last Stone Weight (C++ & Python)
Last Stone Weight | Leetcode 1046 | Max Heap 🔥🔥 | Live coding session
1046. Last Stone Weight - Day 24/30 Leetcode April Challenge
Last Stone Weight | Array | Heaps | 1046 LeetCode | Day 07
Last Stone Weight II - Leetcode 1049 - Python
Last Stone Weight - LeetCode 1046 - JavaScript
1046. Last Stone Weight || LeetCode Solutions
Last Stone Weight - LeetCode 1046 - Python Solution
1046. Last Stone Weight - Day 7/30 Leetcode April Challenge
Leetcode - Last Stone Weight (Python)
LeetCode Day 12 - Last Stone Weight (Priority Queue in C++) with explanation | Errichto Concept |
Day 12 last stone weight || 30 day Leetcode challenge -Coding Shark
30 Day LeetCode Challenge - Last Stone Weight
LeetCode - Last Stone Weight 2 (1049)
1046. Last Stone Weight || Leetcode problem of the day🔥🔥|| Priority queue🔥||max heap🔥
LeetCode 1046: Last Stone Weight - Interview Prep Ep 40
Leetcode day 17|| Last Stone Weight||30 days 30 questions||CodePilot||Harshit
Last Stone Weight [100%] - LeetCode Day 12 Challenge
DAY 53 | 1046. Last Stone Weight | LeetCode 1046 | JAVA
Last Stone Weight | 2 Approaches | GOOGLE | AMAZON | Leetcode 1046
Last Stone Weight | Leetcode 1046 | Priority Queue | Heap | Day -7
Last Stone Weight
Комментарии