Skip to content

Commit d40aa9b

Browse files
committed
Create README - LeetHub
1 parent 01cde2c commit d40aa9b

File tree

1 file changed

+50
-0
lines changed
  • 3442-maximum-difference-between-even-and-odd-frequency-i

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<h2><a href="https://leetcode.com/problems/maximum-difference-between-even-and-odd-frequency-i/?envType=daily-question&envId=2025-06-10">3442. Maximum Difference Between Even and Odd Frequency I</a></h2><h3>Easy</h3><hr><p>You are given a string <code>s</code> consisting of lowercase English letters.</p>
2+
3+
<p>Your task is to find the <strong>maximum</strong> difference <code>diff = freq(a<sub>1)</sub> - freq(a<sub>2</sub>)</code> between the frequency of characters <code>a<sub>1</sub></code> and <code>a<sub>2</sub></code> in the string such that:</p>
4+
5+
<ul>
6+
<li><code>a<sub>1</sub></code> has an <strong>odd frequency</strong> in the string.</li>
7+
<li><code>a<sub>2</sub></code> has an <strong>even frequency</strong> in the string.</li>
8+
</ul>
9+
10+
<p>Return this <strong>maximum</strong> difference.</p>
11+
12+
<p>&nbsp;</p>
13+
<p><strong class="example">Example 1:</strong></p>
14+
15+
<div class="example-block">
16+
<p><strong>Input:</strong> <span class="example-io">s = &quot;aaaaabbc&quot;</span></p>
17+
18+
<p><strong>Output:</strong> 3</p>
19+
20+
<p><strong>Explanation:</strong></p>
21+
22+
<ul>
23+
<li>The character <code>&#39;a&#39;</code> has an <strong>odd frequency</strong> of <code><font face="monospace">5</font></code><font face="monospace">,</font> and <code>&#39;b&#39;</code> has an <strong>even frequency</strong> of <code><font face="monospace">2</font></code>.</li>
24+
<li>The maximum difference is <code>5 - 2 = 3</code>.</li>
25+
</ul>
26+
</div>
27+
28+
<p><strong class="example">Example 2:</strong></p>
29+
30+
<div class="example-block">
31+
<p><strong>Input:</strong> <span class="example-io">s = &quot;abcabcab&quot;</span></p>
32+
33+
<p><strong>Output:</strong> 1</p>
34+
35+
<p><strong>Explanation:</strong></p>
36+
37+
<ul>
38+
<li>The character <code>&#39;a&#39;</code> has an <strong>odd frequency</strong> of <code><font face="monospace">3</font></code><font face="monospace">,</font> and <code>&#39;c&#39;</code> has an <strong>even frequency</strong> of <font face="monospace">2</font>.</li>
39+
<li>The maximum difference is <code>3 - 2 = 1</code>.</li>
40+
</ul>
41+
</div>
42+
43+
<p>&nbsp;</p>
44+
<p><strong>Constraints:</strong></p>
45+
46+
<ul>
47+
<li><code>3 &lt;= s.length &lt;= 100</code></li>
48+
<li><code>s</code> consists only of lowercase English letters.</li>
49+
<li><code>s</code> contains at least one character with an odd frequency and one with an even frequency.</li>
50+
</ul>

0 commit comments

Comments
 (0)