Tap here to switch tabs
Problem
Submissions

Problem: Minimum Array Length After Pair Removals

med
30 min
Try to solve the Minimum Array Length After Pair Removals problem.

Statement

Given a 00-indexed integer array nums sorted in non-decreasing order.

In one operation, you can choose two indices i and j such that i < j and nums[i] < nums[j], and remove the elements at these two indices from nums. The remaining elements keep their original relative order.

Return the minimum possible length of nums after performing this operation any number of times.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤109\leq 10^9

  • nums is sorted in non-decreasing order.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Array Length After Pair Removals

med
30 min
Try to solve the Minimum Array Length After Pair Removals problem.

Statement

Given a 00-indexed integer array nums sorted in non-decreasing order.

In one operation, you can choose two indices i and j such that i < j and nums[i] < nums[j], and remove the elements at these two indices from nums. The remaining elements keep their original relative order.

Return the minimum possible length of nums after performing this operation any number of times.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤109\leq 10^9

  • nums is sorted in non-decreasing order.