# 04.11.2023 [1503. Last Moment Before All Ants Fall Out of a Plank]
Max time ants on a line when going left and right
04.11.2023
1503. Last Moment Before All Ants Fall Out of a Plank medium
blog post
Join me on Telegram
https://t.me/leetcode_daily_unstoppable/392
Problem TLDR
Max time ants on a line when going left and right
Intuition
Use the hint: ants can pass through
Approach
The problem becomes trivial
Complexity
Time complexity:
O(n)Space complexity:
O(1)
Code
fun getLastMoment(n: Int, left: IntArray, right: IntArray): Int =
max(left.maxOrNull() ?: 0, n - (right.minOrNull() ?: n))