1503. Last Moment Before All Ants Fall Out of a Plank
Read the full problem statement on LeetCode.
Difficulty: medium Acceptance: 68% Topics: Array, Brainteaser, Simulation
View full problem on LeetCode Reading material
Reference solution (spoiler · python)
# Time: O(n)
# Space: O(1)
class Solution(object):
def getLastMoment(self, n, left, right):
"""
:type n: int
:type left: List[int]
:type right: List[int]
:rtype: int
"""
return max(max(left or [0]), n-min(right or [n]))
Solution from kamyu104/LeetCode-Solutions · MIT
Similar questions