dsa2 min read
Minimum Cost to Connect Sticks
Find minimum cost to connect all sticks by greedily always merging the two shortest sticks first.
Read →
webcoderspeed.com
6 articles
Find minimum cost to connect all sticks by greedily always merging the two shortest sticks first.
Greedily use ladders for the largest climbs and bricks for smaller gaps, managed with a min-heap of ladder sizes.
Calculate trapped water in a 3D height map using BFS with a min-heap to process cells from shortest boundary inward.
Maximize team performance (sum of speeds * min efficiency) by sorting by efficiency and using a min-heap on speeds.
For each query point, find the smallest interval containing it by sorting both intervals and queries, using a min-heap.
Design a seat manager that reserves the lowest numbered available seat and unreserves seats using a min-heap.