FPEvalRepoPublic/LeetCodeMetaData
0399
1{2 "id": 3753,3 "name": "maximum-difference-between-even-and-odd-frequency-i",4 "difficulty": "Easy",5 "link": "https://leetcode.com/problems/maximum-difference-between-even-and-odd-frequency-i/",6 "date": "2025-01-26",7 "task_description": "You are given a string `s` consisting of lowercase English letters. Your task is to find the **maximum** difference between the frequency of **two** characters in the string such that: One of the characters has an **even frequency** in the string. The other character has an **odd frequency** in the string. Return the **maximum** difference, calculated as the frequency of the character with an odd frequency **minus** the frequency of the character with an even frequency. **Example 1:** **Input:** s = \"aaaaabbc\" **Output:** 3 **Explanation:** The character `'a'` has an **odd frequency** of `5`, and `'b'` has an **even frequency** of `2`. The maximum difference is `5 - 2 = 3`. **Example 2:** **Input:** s = \"abcabcab\" **Output:** 1 **Explanation:** The character `'a'` has an **odd frequency** of `3`, and `'c'` has an **even frequency** of 2. The maximum difference is `3 - 2 = 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.",8 "test_case": [9 {10 "label": "Example 1",11 "input": "s = \"aaaaabbc\"",12 "output": "3 "13 },14 {15 "label": "Example 2",16 "input": "s = \"abcabcab\"",17 "output": "1 "18 }19 ],20 "constraints": [21 "One of the characters has an even frequency in the string.",22 "The other character has an odd frequency in the string.",23 "The character 'a' has an odd frequency of 5, and 'b' has an even frequency of 2.",24 "The maximum difference is 5 - 2 = 3.",25 "The character 'a' has an odd frequency of 3, and 'c' has an even frequency of 2.",26 "The maximum difference is 3 - 2 = 1.",27 "3 <= s.length <= 100",28 "s consists only of lowercase English letters.",29 "s contains at least one character with an odd frequency and one with an even frequency."30 ],31 "python_template": "class Solution(object):\n def maxDifference(self, s):\n \"\"\"\n :type s: str\n :rtype: int\n \"\"\"\n ",32 "java_template": "class Solution {\n public int maxDifference(String s) {\n \n }\n}",33 "metadata": {34 "func_name": "maxDifference"35 }36}