3018. Maximum Number of Removal Queries That Can Be Processed I
You are given a 0-indexed array
numsand a 0-indexed arrayqueries.You can do the following operation at the beginning at most once:
- Replace
numswith 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
numsis less thanqueries[i], the processing of queries ends.- Otherwise, we choose either the first or the last element of
numsif 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 { |