3480. Maximize Subarrays After Removing One Conflicting Pair
You are given an integer
n
which represents an arraynums
containing the numbers from 1 ton
in order. Additionally, you are given a 2D arrayconflictingPairs
, whereconflictingPairs[i] = [a, b]
indicates thata
andb
form a conflicting pair.Remove exactly one element from
conflictingPairs
. Afterward, count the number of non-empty subarrays ofnums
which do not contain botha
andb
for any remaining conflicting pair[a, b]
.Return the maximum number of subarrays possible after removing exactly one conflicting pair.
c++
1 |
|