Tap here to switch tabs
Problem
Submissions

Problem: Sorting Three Groups

med
30 min
Try to solve the Sorting Three Groups problem.

Statement

You are given an integer array nums where every element is either 11, 22, or 33.

In one operation, you can select any index and change its value to any integer from 11 to 33, inclusive.

Return the minimum number of operations required to make nums nondecreasing.

Constraints:

  • 1≤1 \leq nums.length ≤100\leq 100

  • 1≤1 \leq nums[i] ≤3\leq 3

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Sorting Three Groups

med
30 min
Try to solve the Sorting Three Groups problem.

Statement

You are given an integer array nums where every element is either 11, 22, or 33.

In one operation, you can select any index and change its value to any integer from 11 to 33, inclusive.

Return the minimum number of operations required to make nums nondecreasing.

Constraints:

  • 1≤1 \leq nums.length ≤100\leq 100

  • 1≤1 \leq nums[i] ≤3\leq 3