You are using an outdated browser. Please update your browser for a better user experience.

K'th Largest Element

heaps

Given an array of numbers A, and positive integer k, find the K'th largest element in the array.

Example:

INPUT:
A = [5, 5, 9, 10, 2, 12, 3, 6] , k = 3

OUTPUT:
K'th largest element in the array is 9

Notes:
1 ≤ k ≤ n
The given array will not necessarily be sorted
This problem is b...

Last Stone Weight

trees heaps

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 less than or equal to y. The result of this smash is:

If x == y, both stones are totally destroyed;
...

Merge Lists of Different Lengths

heaps


Alright so you have an assortment of sorted lists.
Unfortunately for you, they're of varying lengths.

So to rub some more salt on the wound, make it into a heap!
If I were you, I would ditch the whole multiple arrays and make one big one.
This would obviously mean that you would need to do...