Skip to content

Instantly share code, notes, and snippets.

@munguial
Created April 7, 2020 07:08
Show Gist options
  • Save munguial/991bc71fe17882d90934ec683c1a5a77 to your computer and use it in GitHub Desktop.
Save munguial/991bc71fe17882d90934ec683c1a5a77 to your computer and use it in GitHub Desktop.
Day 7 - Counting elements
# https://leetcode.com/explore/challenge/card/30-day-leetcoding-challenge/528/week-1/3289/
class Solution:
def countElements(self, arr: List[int]) -> int:
s = set(arr)
c = 0
for n in arr:
if n + 1 in s:
c += 1
return c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment