3018. Maximum Number of Removal Queries That Can Be Processed I
You are given a 0-indexed array
nums
and a 0-indexed arrayqueries
.You can do the following operation at the beginning at most once:
- Replace
nums
with a subsequence ofnums
.We start processing queries in the given order; for each query, we do the following:
- If the first and the last element of
nums
is less thanqueries[i]
, the processing of queries ends.- Otherwise, we choose either the first or the last element of
nums
if it is greater than or equal toqueries[i]
, and we remove the chosen element fromnums
.Return the maximum number of queries that can be processed by doing the operation optimally.
1 | class Solution { |