Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1111730

Browse files
Add solution to leetcode 1512
1 parent 04a3133 commit 1111730

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

‎1207-Unique Number of Occurrences.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@ def uniqueOccurrences(arr):
1717
unique_occ.add(occ)
1818

1919
return True
20+
21+
print("Hello")

‎1512-Number of Good Pairs.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Link to problem: https://leetcode.com/problems/number-of-good-pairs/
2+
3+
def numIdenticalPairs(nums):
4+
num_count = {}
5+
for n in nums:
6+
if n not in num_count:
7+
num_count[n] = 1
8+
else:
9+
num_count[n] += 1
10+
11+
good_pairs = 0
12+
13+
for count in num_count.values():
14+
good_pairs += (count*(count-1))//2
15+
16+
return good_pairs
17+

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /