Tap here to switch tabs
Problem
Submissions

Problem: Minimize Length of Array Using Operations

med
30 min
Try to solve the Minimize Length of Array Using Operations problem.

Statement

You are given an integer array nums consisting of positive integers.

You can perform the following operation any number of times:

  1. Choose two distinct indices i and j such that nums[i] > 00 and nums[j] > 00.

  2. Append the value of nums[i] % nums[j] to the end of nums.

  3. Remove the elements at indices i and j from nums.

Return an integer representing the minimum possible length of nums after performing the operation any number of times.

Constraints:

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

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

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimize Length of Array Using Operations

med
30 min
Try to solve the Minimize Length of Array Using Operations problem.

Statement

You are given an integer array nums consisting of positive integers.

You can perform the following operation any number of times:

  1. Choose two distinct indices i and j such that nums[i] > 00 and nums[j] > 00.

  2. Append the value of nums[i] % nums[j] to the end of nums.

  3. Remove the elements at indices i and j from nums.

Return an integer representing the minimum possible length of nums after performing the operation any number of times.

Constraints:

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

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