Open fockspaces opened 9 months ago
the ternary condiftion will check if first, so we can write like this one without index Erorr:
min_from_left = left_half[0] if left_half else float('inf')
min_from_right = right_half[0] if right_half else float('inf')
everytime we pick min cost from first k elements or last k elements. we can simply using for loop to lookup the suitable value each time, but will TLE eventually
the best way is to use space to record the next ready to pop out value from each side, then keep filling candiadate for each side