Last Moment Before All Ants Fall Out of a Plank LeetCode solution in Python
1# Runtime: 316 ms (Top 23.17%) | Memory: 15 MB (Top 18.90%)2class Solution:3def getLastMoment(self, n: int, left: List[int], right: List[int]) -> int:4# make sure left and right are not empty without changing the answer5left.append(0)6right.append(n)78return max(max(left), n - min(right))