dsa2 min read
Minimize Deviation in Array
Minimize max-min of an array by doubling odd numbers and repeatedly halving the max using a max-heap.
Read →
1575 articles
Minimize max-min of an array by doubling odd numbers and repeatedly halving the max using a max-heap.
Extended practice: compute median for each window in a stream using two-heap with lazy deletion pattern.
For each query point, find the smallest interval containing it by sorting both intervals and queries, using a min-heap.
For each interval find the interval with the smallest start point >= the end point using sorted starts and binary search.
Sort array elements by frequency ascending, breaking ties by value descending.