Skip to content

Latest commit

 

History

History
13 lines (11 loc) · 354 Bytes

1503. Last Moment Before All Ants Fall Out of a Plank.md

File metadata and controls

13 lines (11 loc) · 354 Bytes

Code for ' 1503. Last Moment Before All Ants Fall Out of a Plank ' ( C++ )

class Solution {
 public:
  int getLastMoment(int n, vector<int>& left, vector<int>& right) {
    const int maxLeft = left.empty() ? 0 : ranges::max(left);
    const int minRight = right.empty() ? n : ranges::min(right);
    return max(maxLeft, n - minRight);
  }
};