Skip to main content
Back to problems
Leetcode
Medium
Arrays
Strings
Greedy
Minimum Operations To Make A Rotated Palindrome I

Find the minimum number of operations needed to transform an array or string into some rotation that is a palindrome.

Acceptance 0%
Problem Statement

You are given a sequence of values. In one operation, you may change an element so that the sequence can be rearranged through rotation into a palindrome. Determine the minimum number of changes required to make some cyclic rotation of the sequence a palindrome.

A rotation chooses a starting position and reads the sequence circularly from that point. The goal is to perform the fewest modifications so that at least one rotation becomes a palindrome.

Input Format

  • A sequence of length nn represented as an array or string.
  • You may assume the sequence is finite and indexable.
  • The exact input encoding depends on the platform wrapper.

Output Format

  • Return a single integer: the minimum number of modifications needed so that some rotation of the sequence is a palindrome.

Constraints

  • The sequence length is positive.
  • A palindrome reads the same forward and backward.
  • A rotation uses the sequence cyclically; no elements are removed or reordered beyond choosing the start position.
  • Exact platform constraints are not provided in the source metadata.
Examples
Sample cases returned by the problem API.

Example 1

Input

s = "aabca"

Output

1

Explanation

One change can make a rotation palindromic, for example by changing one character so that an appropriate cyclic shift reads the same forward and backward.

Premium problem context

Unlock deeper context for this problem

Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.

Guided hints
Editorial and discussion links
Concept map and variants
Sign in to unlock
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.