Skip to content

Commit a91bc13

Browse files
Zanger67/leetcodeZanger67/leetcode
authored andcommitted
Updated markdown files
1 parent aca3683 commit a91bc13

9 files changed

+72
-22
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# **[LeetCode Records](https://leetcode.com/u/Zanger/)** (620 solved)
1+
# **[LeetCode Records](https://leetcode.com/u/Zanger/)** (621 solved)
22

33
<!-- This readme was generated using [WikiLeet](<https://github.com/Zanger67/WikiLeet>) -->
44

@@ -660,6 +660,7 @@ This repo is a collection of my LeetCode solutions, primarily written in Python,
660660
| 3248 | [Snake in Matrix](<https://leetcode.com/problems/snake-in-matrix>) | Easy | | [solution](<markdowns/_3248. Snake in Matrix.md>) | py |
661661
| 3249 | [Count the Number of Good Nodes](<https://leetcode.com/problems/count-the-number-of-good-nodes>) | Medium | | [solution](<markdowns/_3249. Count the Number of Good Nodes.md>) | py |
662662
| 3306 | [Count of Substrings Containing Every Vowel and K Consonants II](<https://leetcode.com/problems/count-of-substrings-containing-every-vowel-and-k-consonants-ii>) | Medium | Daily | [solution](<markdowns/_3306. Count of Substrings Containing Every Vowel and K Consonants II.md>) | py |
663+
| 3396 | [Minimum Number of Operations to Make Elements in Array Distinct](<https://leetcode.com/problems/minimum-number-of-operations-to-make-elements-in-array-distinct>) | Easy | Daily | [solution](<markdowns/_3396. Minimum Number of Operations to Make Elements in Array Distinct.md>) | py |
663664
| 3443 | [Maximum Manhattan Distance After K Changes](<https://leetcode.com/problems/maximum-manhattan-distance-after-k-changes>) | Medium | | [solution](<markdowns/_3443. Maximum Manhattan Distance After K Changes.md>) | py |
664665
| 3460 | [Longest Common Prefix After at Most One Removal](<https://leetcode.com/problems/longest-common-prefix-after-at-most-one-removal>) | Medium | | [solution](<markdowns/_3460. Longest Common Prefix After at Most One Removal.md>) | py |
665666

markdowns/Daily_Questions.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,19 @@
55
Dates are for the date I completed the question so due to the my time zone and how it lines up with UTC, it may be off by a day.
66

77
### April 2025
8-
| Su | Mo | Tu | We | Th | Fr | Sa |
9-
|-----:|-------------------------------------------:|-----:|-------------------------------------------------------:|-----:|-----:|-----:|
10-
| | | 1 | [2](<_2873. Maximum Value of an Ordered Triplet I.md>) | 3 | 4 | 5 |
11-
| 6 | [7](<_416. Partition Equal Subset Sum.md>) | 8 | 9 | 10 | 11 | 12 |
12-
| 13 | 14 | 15 | 16 | 17 | 18 | 19 |
13-
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
14-
| 27 | 28 | 29 | 30 | | | |
8+
| Su | Mo | Tu | We | Th | Fr | Sa |
9+
|-----:|-------------------------------------------:|---------------------------------------------------------------------------------:|-------------------------------------------------------:|-----:|-----:|-----:|
10+
| | | 1 | [2](<_2873. Maximum Value of an Ordered Triplet I.md>) | 3 | 4 | 5 |
11+
| 6 | [7](<_416. Partition Equal Subset Sum.md>) | [8](<_3396. Minimum Number of Operations to Make Elements in Array Distinct.md>) | 9 | 10 | 11 | 12 |
12+
| 13 | 14 | 15 | 16 | 17 | 18 | 19 |
13+
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
14+
| 27 | 28 | 29 | 30 | | | |
1515

1616

1717

1818
| # | Title | Level | Cats | Solution | Languages | Date Complete |
1919
|-----:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------|:---------------|:----------------------------------------------------------------------------------------------------|:-----------------------------|:----------------|
20+
| 3396 | [Minimum Number of Operations to Make Elements in Array Distinct](<https://leetcode.com/problems/minimum-number-of-operations-to-make-elements-in-array-distinct>) | Easy | Daily | [solution](<_3396. Minimum Number of Operations to Make Elements in Array Distinct.md>) | py | Apr 08, 2025 |
2021
| 416 | [Partition Equal Subset Sum](<https://leetcode.com/problems/partition-equal-subset-sum>) | Medium | Daily, N150 | [solution](<_416. Partition Equal Subset Sum.md>) | py | Apr 07, 2025 |
2122
| 2873 | [Maximum Value of an Ordered Triplet I](<https://leetcode.com/problems/maximum-value-of-an-ordered-triplet-i>) | Easy | Daily | [solution](<_2873. Maximum Value of an Ordered Triplet I.md>) | py | Apr 02, 2025 |
2223
| 3169 | Weekly Contest 400 - q2 - [Count Days Without Meetings](<https://leetcode.com/problems/count-days-without-meetings>) | Medium | Contest, Daily | [solution](<_3169. Count Days Without Meetings.md>) | py | Mar 24, 2025 |
@@ -275,11 +276,11 @@ Dates are for the date I completed the question so due to the my time zone and h
275276

276277

277278
### April 2025
278-
| Su | Mo | Tu | We | Th | Fr | Sa |
279-
|-----:|-------------------------------------------:|-----:|-------------------------------------------------------:|-----:|-----:|-----:|
280-
| | | 1 | [2](<_2873. Maximum Value of an Ordered Triplet I.md>) | 3 | 4 | 5 |
281-
| 6 | [7](<_416. Partition Equal Subset Sum.md>) | 8 | 9 | 10 | 11 | 12 |
282-
| 13 | 14 | 15 | 16 | 17 | 18 | 19 |
283-
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
284-
| 27 | 28 | 29 | 30 | | | |
279+
| Su | Mo | Tu | We | Th | Fr | Sa |
280+
|-----:|-------------------------------------------:|---------------------------------------------------------------------------------:|-------------------------------------------------------:|-----:|-----:|-----:|
281+
| | | 1 | [2](<_2873. Maximum Value of an Ordered Triplet I.md>) | 3 | 4 | 5 |
282+
| 6 | [7](<_416. Partition Equal Subset Sum.md>) | [8](<_3396. Minimum Number of Operations to Make Elements in Array Distinct.md>) | 9 | 10 | 11 | 12 |
283+
| 13 | 14 | 15 | 16 | 17 | 18 | 19 |
284+
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
285+
| 27 | 28 | 29 | 30 | | | |
285286

markdowns/Easy.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Easy Questions (180)
1+
# Easy Questions (181)
22

33
*[Back to top](<../README.md>)*
44

@@ -185,4 +185,5 @@
185185
| 3232 | Weekly Contest 408 - q1 - [Find if Digit Game Can Be Won](<https://leetcode.com/problems/find-if-digit-game-can-be-won>) | Easy | Contest | [solution](<_3232. Find if Digit Game Can Be Won.md>) | py | Jul 28, 2024 |
186186
| 3238 | Biweekly Contest 136 - q1 - [Find the Number of Winning Players](<https://leetcode.com/problems/find-the-number-of-winning-players>) | Easy | Contest | [solution](<_3238. Find the Number of Winning Players.md>) | py | Aug 03, 2024 |
187187
| 3242 | [Design Neighbor Sum Service](<https://leetcode.com/problems/design-neighbor-sum-service>) | Easy | | [solution](<_3242. Design Neighbor Sum Service.md>) | py | Aug 04, 2024 |
188-
| 3248 | [Snake in Matrix](<https://leetcode.com/problems/snake-in-matrix>) | Easy | | [solution](<_3248. Snake in Matrix.md>) | py | Aug 12, 2024 |
188+
| 3248 | [Snake in Matrix](<https://leetcode.com/problems/snake-in-matrix>) | Easy | | [solution](<_3248. Snake in Matrix.md>) | py | Aug 12, 2024 |
189+
| 3396 | [Minimum Number of Operations to Make Elements in Array Distinct](<https://leetcode.com/problems/minimum-number-of-operations-to-make-elements-in-array-distinct>) | Easy | Daily | [solution](<_3396. Minimum Number of Operations to Make Elements in Array Distinct.md>) | py | Apr 08, 2025 |

markdowns/Questions_By_Code_Length.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,7 @@ Calculations are based on the code files's byte sizes.
513513
| 945 | [Minimum Increment to Make Array Unique](<https://leetcode.com/problems/minimum-increment-to-make-array-unique>) | Medium | Daily | [solution](<_945. Minimum Increment to Make Array Unique.md>) | py | Jun 14, 2024 |
514514
| 1376 | [Time Needed to Inform All Employees](<https://leetcode.com/problems/time-needed-to-inform-all-employees>) | Medium | | [solution](<_1376. Time Needed to Inform All Employees.md>) | py | Oct 26, 2024 |
515515
| 977 | [Squares of a Sorted Array](<https://leetcode.com/problems/squares-of-a-sorted-array>) | Easy | | [solution](<_977. Squares of a Sorted Array.md>) | py | Jun 21, 2024 |
516+
| 3396 | [Minimum Number of Operations to Make Elements in Array Distinct](<https://leetcode.com/problems/minimum-number-of-operations-to-make-elements-in-array-distinct>) | Easy | Daily | [solution](<_3396. Minimum Number of Operations to Make Elements in Array Distinct.md>) | py | Apr 08, 2025 |
516517
| 1780 | [Check if Number is a Sum of Powers of Three](<https://leetcode.com/problems/check-if-number-is-a-sum-of-powers-of-three>) | Medium | Daily | [solution](<_1780. Check if Number is a Sum of Powers of Three.md>) | py | Mar 04, 2025 |
517518
| 1748 | [Sum of Unique Elements](<https://leetcode.com/problems/sum-of-unique-elements>) | Easy | | [solution](<_1748. Sum of Unique Elements.md>) | c | Jun 06, 2024 |
518519
| 1436 | [Destination City](<https://leetcode.com/problems/destination-city>) | Easy | | [solution](<_1436. Destination City.md>) | java | Jun 01, 2024 |

markdowns/Questions_By_Recent.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Calculations are based on the date of the first solve.
66

77
| # | Title | Level | Cats | Solution | Languages | Date Complete |
88
|-----:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------|:--------------------------|:----------------------------------------------------------------------------------------------------|:--------------------------------------------|:----------------|
9+
| 3396 | [Minimum Number of Operations to Make Elements in Array Distinct](<https://leetcode.com/problems/minimum-number-of-operations-to-make-elements-in-array-distinct>) | Easy | Daily | [solution](<_3396. Minimum Number of Operations to Make Elements in Array Distinct.md>) | py | Apr 08, 2025 |
910
| 416 | [Partition Equal Subset Sum](<https://leetcode.com/problems/partition-equal-subset-sum>) | Medium | Daily, N150 | [solution](<_416. Partition Equal Subset Sum.md>) | py | Apr 07, 2025 |
1011
| 2873 | [Maximum Value of an Ordered Triplet I](<https://leetcode.com/problems/maximum-value-of-an-ordered-triplet-i>) | Easy | Daily | [solution](<_2873. Maximum Value of an Ordered Triplet I.md>) | py | Apr 02, 2025 |
1112
| 1055 | [Shortest Way to Form String](<https://leetcode.com/problems/shortest-way-to-form-string>) | Medium | Weekly Premium | [solution](<_1055. Shortest Way to Form String.md>) | py | Mar 30, 2025 |

markdowns/Topics.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
------
66

7-
- [Array](<by_topic/Array.md>) (305 completed)
7+
- [Array](<by_topic/Array.md>) (306 completed)
88
- [String](<by_topic/String.md>) (146 completed)
9-
- [Hash Table](<by_topic/Hash Table.md>) (138 completed)
9+
- [Hash Table](<by_topic/Hash Table.md>) (139 completed)
1010
- [Depth-First Search](<by_topic/Depth-First Search.md>) (103 completed)
1111
- [Tree](<by_topic/Tree.md>) (91 completed)
1212
- [Binary Tree](<by_topic/Binary Tree.md>) (82 completed)
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# 3396. [Minimum Number of Operations to Make Elements in Array Distinct](<https://leetcode.com/problems/minimum-number-of-operations-to-make-elements-in-array-distinct>)
2+
3+
*All prompts are owned by LeetCode. To view the prompt, click the title link above.*
4+
5+
*[Back to top](<../README.md>)*
6+
7+
------
8+
9+
> *First completed : April 08, 2025*
10+
>
11+
> *Last updated : April 08, 2025*
12+
13+
------
14+
15+
> **Related Topics** : **[Array](<by_topic/Array.md>), [Hash Table](<by_topic/Hash Table.md>)**
16+
>
17+
> **Acceptance Rate** : **57.47 %**
18+
19+
------
20+
21+
## Solutions
22+
23+
- [e3396.py](<../my-submissions/e3396.py>)
24+
### Python
25+
#### [e3396.py](<../my-submissions/e3396.py>)
26+
```Python
27+
class Solution:
28+
def minimumOperations(self, nums: List[int]) -> int:
29+
cnt = Counter(nums)
30+
above = sum([1 for v in cnt.values() if v > 1])
31+
32+
for i, c in enumerate(nums) :
33+
if above == 0 :
34+
return ceil(i / 3)
35+
if cnt[c] == 1 :
36+
cnt.pop(c)
37+
cnt[c] -= 1
38+
if cnt[c] == 1 :
39+
above -= 1
40+
41+
return ceil(len(nums) / 3)
42+
```
43+

0 commit comments

Comments
 (0)