Skip to content

Commit b6152e5

Browse files
committed
day7
1 parent 6c8fa1e commit b6152e5

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.vscode/settings.json
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
'''Given an integer array arr, count element x such that x + 1 is also in arr.
2+
If there're duplicates in arr, count them seperately.'''
3+
4+
class Solution(object):
5+
def countElements(self, arr):
6+
"""
7+
:type arr: List[int]
8+
:rtype: int
9+
"""
10+
count = 0
11+
arr.sort()
12+
for i in arr:
13+
if i+1 in arr:
14+
count+=1
15+
return count
16+

0 commit comments

Comments
 (0)