Blogs Hub

by AskGif | Oct 04, 2020 | Category :coding

Last Stone Weight - Heap - Easy - LeetCode

Last Stone Weight - Heap - Easy - LeetCode

We have 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 <= y.  The result of this smash is: If x == y, both stones are totally destroy

read more...

by AskGif | Jan 03, 2019 | Category :coding

What is a Heap?

What is a Heap?

A heap is a tree with some special properties. The basic requirement of a heap is that the value of a node must be > (or <) than the values of its children. This is called heap property. A heap also has the additional property that all leaves should be at h or h – 1 le

read more...