mediumArrayBinary SearchCountingGreedyHash TableTwo Pointers 0 views

Minimum Array Length After Pair Removals

Given an integer array num sorted in non-decreasing order.

Given an integer array num sorted in non-decreasing order.

You can perform the following operation any number of times:

Return the minimum length of nums after applying the operation zero or more times.

Minimum Array Length After Pair Removals diagram

Example 1

Input: nums = [1,2,3,4]

Output: 0

Example 2

Input: nums = [1,1,2,2,3,3]

Output: 0

Example 3

Input: nums = [1000000000,1000000000]

Output: 2

Explanation: Since both numbers are equal, they cannot be removed.

Example 4

Input: nums = [2,3,4,4,4]

Output: 1

Constraints

  • 1 <= nums.length <= 10^5
  • 1 <= nums[i] <= 10^9
  • nums is sorted in non-decreasing order.

Hints

Companies

No companies reported yet.

Discussion

Sign in to join the discussion.

Loading discussion...

Test results

No test cases yet.