Skip to content

Practice Maximum Difference Between Even and Odd Frequency I

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

Easy#3442
LeetCode Problem

Maximum Difference Between Even and Odd Frequency I

Problem Statement

Given a lowercase string s, choose one character with odd frequency and another with positive even frequency in s. Return the maximum possible value of the odd frequency minus the even frequency.

Source: Maximum Difference Between Even and Odd Frequency I on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
s = "aaaaabbc"
Output
3

# Example 2

Input
s = "abcabcab"
Output
1

Constraints

3 <= s.length <= 100
s consists only of lowercase English letters.
s contains at least one character with an odd frequency and one with an even frequency.

Related LeetCode Problems

Practice more problems similar to Maximum Difference Between Even and Odd Frequency I.

Review your practice with PhantomCodeAI

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