dsa1 min read
Successful Pairs of Spells and Potions — Sort + Binary Search
Count spell-potion pairs with product >= success by sorting potions and binary searching for each spell's threshold.
Read →
webcoderspeed.com
1276 articles
Count spell-potion pairs with product >= success by sorting potions and binary searching for each spell's threshold.
Find the kth smallest element in a row-column sorted matrix by binary searching on the value range.
Maximize the minimum distance between m balls in baskets using binary search on the answer (minimum distance).
Find the minimum in a rotated array with duplicates by shrinking hi-- when nums[mid]==nums[hi].
Find the median of two sorted arrays in O(log(min(m,n))) by binary searching for the correct partition point.