MathWorks Interview Question

k heap from leetcode , threads and cs concepts