LeetCode Entry
1503. Last Moment Before All Ants Fall Out of a Plank
Max time ants on a line when goint left and right
1503. Last Moment Before All Ants Fall Out of a Plank medium
blog post
substack

Join me on Telegram
https://t.me/leetcode_daily_unstoppable/392
Problem TLDR
Max time ants on a line when goint 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))