Open fockspaces opened 6 months ago
The hard part is to figure out the CHOICES direction why can't sort by nums1 from max to min and take the order?
since we want to find the next element to update min_value if it comes to new_n1 for updating, the k elements in nums2 is not neccessary related since the min value might be any of them.
so we need to keep track the losing num_1 in each iteration for updating n1_sum
incredibly hard problem ...
Use : Greedy + heap_q since we want the maximun value of sum(a, b, c) * min(a', b', c') we can first figure out a sorted order that can help us to keep tracking the max possible combination. then we only care about value of nums1, since nums2 is in descending order, means that nums2 will constantly update the min value for each iteration
https://www.youtube.com/watch?v=ax1DKi5lJwk&ab_channel=NeetCodeIO