Skip to content

Commit 12ba62e

Browse files
committed
Create README - LeetHub
1 parent dd44db5 commit 12ba62e

File tree

1 file changed

+55
-0
lines changed
  • 3347-maximum-frequency-of-an-element-after-performing-operations-ii

1 file changed

+55
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<h2><a href="https://leetcode.com/problems/maximum-frequency-of-an-element-after-performing-operations-ii/">3347. Maximum Frequency of an Element After Performing Operations II</a></h2><h3>Hard</h3><hr><div><p>You are given an integer array <code>nums</code> and two integers <code>k</code> and <code>numOperations</code>.</p>
2+
3+
<p>You must perform an <strong>operation</strong> <code>numOperations</code> times on <code>nums</code>, where in each operation you:</p>
4+
5+
<ul>
6+
<li>Select an index <code>i</code> that was <strong>not</strong> selected in any previous operations.</li>
7+
<li>Add an integer in the range <code>[-k, k]</code> to <code>nums[i]</code>.</li>
8+
</ul>
9+
10+
<p>Return the <strong>maximum</strong> possible <span data-keyword="frequency-array">frequency</span> of any element in <code>nums</code> after performing the <strong>operations</strong>.</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">nums = [1,4,5], k = 1, numOperations = 2</span></p>
17+
18+
<p><strong>Output:</strong> <span class="example-io">2</span></p>
19+
20+
<p><strong>Explanation:</strong></p>
21+
22+
<p>We can achieve a maximum frequency of two by:</p>
23+
24+
<ul>
25+
<li>Adding 0 to <code>nums[1]</code>, after which <code>nums</code> becomes <code>[1, 4, 5]</code>.</li>
26+
<li>Adding -1 to <code>nums[2]</code>, after which <code>nums</code> becomes <code>[1, 4, 4]</code>.</li>
27+
</ul>
28+
</div>
29+
30+
<p><strong class="example">Example 2:</strong></p>
31+
32+
<div class="example-block">
33+
<p><strong>Input:</strong> <span class="example-io">nums = [5,11,20,20], k = 5, numOperations = 1</span></p>
34+
35+
<p><strong>Output:</strong> <span class="example-io">2</span></p>
36+
37+
<p><strong>Explanation:</strong></p>
38+
39+
<p>We can achieve a maximum frequency of two by:</p>
40+
41+
<ul>
42+
<li>Adding 0 to <code>nums[1]</code>.</li>
43+
</ul>
44+
</div>
45+
46+
<p>&nbsp;</p>
47+
<p><strong>Constraints:</strong></p>
48+
49+
<ul>
50+
<li><code>1 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
51+
<li><code>1 &lt;= nums[i] &lt;= 10<sup>9</sup></code></li>
52+
<li><code>0 &lt;= k &lt;= 10<sup>9</sup></code></li>
53+
<li><code>0 &lt;= numOperations &lt;= nums.length</code></li>
54+
</ul>
55+
</div>

0 commit comments

Comments
 (0)