Skip to content

Practice Minimum Number of Moves to Make Palindrome

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

Hard#2193
LeetCode Problem

Minimum Number of Moves to Make Palindrome

Problem Statement

You are given a string s consisting only of lowercase English letters. In one move, you can select any two adjacent characters of s and swap them. Return the minimum number of moves needed to make s a palindrome. Note that the input will be generated such that s can always be converted to a palindrome.

Source: Minimum Number of Moves to Make Palindrome on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
s = "aabb"
Output
2

# Example 2

Input
s = "letelt"
Output
2

Constraints

1 <= s.length <= 2000
s consists only of lowercase English letters.
s can be converted to a palindrome using a finite number of moves.

Related LeetCode Problems

Practice more problems similar to Minimum Number of Moves to Make Palindrome.

Review your practice with PhantomCodeAI

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