Skip to content

Practice Find Minimum Operations to Make All Elements Divisible by Three

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#3190
LeetCode Problem

Find Minimum Operations to Make All Elements Divisible by Three

Problem Statement

You are given an integer array nums. In one operation, you can add or subtract 1 from any element of nums. Return the minimum number of operations to make all elements of nums divisible by 3.

Source: Find Minimum Operations to Make All Elements Divisible by Three on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

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

# Example 2

Input
nums = [3,6,9]
Output
0

Constraints

1 <= nums.length <= 50
1 <= nums[i] <= 50

Related LeetCode Problems

Practice more problems similar to Find Minimum Operations to Make All Elements Divisible by Three.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.