I’m doing leetcode problem 2513. Minimize the Maximum of Two Arrays. But my question is about the behavior of python’s bisect_left function.
class Solution:
def minimizeSet(self, D1: int, D2: int, C1: int, C2: int) -> int:
return bisect_left(range(10**10), True, key=lambda M: M-M//D1 >= C1 and
M-M//D2 >= C2 and
M-M//lcm(D1,D2) >= C1+C2)
However, if I do
class Solution:
def minimizeSet(self, D1: int, D2: int, C1: int, C2: int) -> int:
return bisect_left(3, range(10**10), True, key=lambda M: M-M//D1 >= C1 and
M-M//D2 >= C2 and
M-M//lcm(D1,D2) >= C1+C2)
The bisect_left call actually ends up returning 1, which is lower than 3. I’m quite confused about why this happening, since I expect bisect_left to basically perform a binary search on the range (3, 10**10).
Any input would be appreciated