We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6c8fa1e commit b6152e5Copy full SHA for b6152e5
.gitignore
@@ -0,0 +1 @@
1
+.vscode/settings.json
Leetcode_30days/day7_CountingElements.py
@@ -0,0 +1,16 @@
+'''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