#2856
Minimum Array Length After Pair Removals
expert · 1160 · lc medium +32 · 27.1% accepted · 422 likes · top 5%
Description
An integer array num sorted in non-decreasing order is given.
You may perform the following operation any number of times:
- Pick indices i and j where nums[i] < nums[j].
- Remove both elements; the remaining elements keep their order and are re-indexed.
Return the minimum possible length of nums after zero or more operations.
Code
1
2
3