Tap here to switch tabs
Problem
Submissions

Problem: Maximum Palindromes After Operations

Try to solve the Maximum Palindromes After Operations problem.

Statement

You are given an array of strings words.

In one operation, you may choose four indices i, j, x, and y such that 0≤0 \leq i, j << words.length, 0≤0 \leq x << words[i].length, and 0≤0 \leq y << words[j].length, and swap the characters words[i][x] and words[j][y].

You are allowed to apply this operation any number of times.

Return the maximum number of palindromic strings that words can contain after performing any number of operations.

Note: A string is a palindrome if it reads the same forward and backward.

Constraints:

  • 1≤1 \leq words.length ≤1000\leq 1000

  • 1≤1 \leq words[i].length ≤100\leq 100

  • words[i] consists only of lowercase English letters.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Palindromes After Operations

Try to solve the Maximum Palindromes After Operations problem.

Statement

You are given an array of strings words.

In one operation, you may choose four indices i, j, x, and y such that 0≤0 \leq i, j << words.length, 0≤0 \leq x << words[i].length, and 0≤0 \leq y << words[j].length, and swap the characters words[i][x] and words[j][y].

You are allowed to apply this operation any number of times.

Return the maximum number of palindromic strings that words can contain after performing any number of operations.

Note: A string is a palindrome if it reads the same forward and backward.

Constraints:

  • 1≤1 \leq words.length ≤1000\leq 1000

  • 1≤1 \leq words[i].length ≤100\leq 100

  • words[i] consists only of lowercase English letters.