package
Version:
v0.0.0-...-5ea41ec
Opens a new window with list of versions in this module.
Published: Jun 12, 2025
License: MIT
Opens a new window with license information.
Imports: 1
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
README
¶
奇偶频次间的最大差值 I
给你一个由小写英文字母组成的字符串 s
。
请你找出字符串中两个字符 a1
和 a2
的出现频次之间的 最大 差值 diff = freq(a1) - freq(a2)
,这两个字符需要满足:
a1
在字符串中出现 奇数次 。
a2
在字符串中出现 偶数次 。
返回 最大 差值。
示例 1:
**输入:**s = "aaaaabbc"
**输出:**3
解释:
- 字符
'a'
出现 奇数次 ,次数为 5
;字符'b'
出现 偶数次 ,次数为 2
。
- 最大差值为
5 - 2 = 3
。
示例 2:
**输入:**s = "abcabcab"
**输出:**1
解释:
- 字符
'a'
出现 奇数次 ,次数为 3
;字符'c'
出现 偶数次 ,次数为 2 。
- 最大差值为
3 - 2 = 1
。
提示:
3 <= s.length <= 100
s
仅由小写英文字母组成。
s
至少由一个出现奇数次的字符和一个出现偶数次的字符组成。
Documentation
¶
There is no documentation for this package.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.