Skip to content

Practice Minimum Seconds to Equalize a Circular Array

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

Medium#2808
LeetCode Problem

Minimum Seconds to Equalize a Circular Array

Problem Statement

Every second, simultaneously replace each nums entry with its own current value or either current neighboring value, treating the array as circular. Return the minimum seconds needed to make all entries equal.

Source: Minimum Seconds to Equalize a Circular Array on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

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

# Example 2

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

# Example 3

Input
nums = [5,5,5,5]
Output
0

Constraints

1 <= n == nums.length <= 10^5
1 <= nums[i] <= 10^9

Related LeetCode Problems

Practice more problems similar to Minimum Seconds to Equalize a Circular Array.

Review your practice with PhantomCodeAI

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