@@ -0,0 +1,992 @@
+%22%22%22%0D%0AGiven an integer array arr, count element x such that x + 1 is also in arr.%0D%0A%0D%0AIf there're duplicates in arr, count them seperately.%0D%0A%0D%0A%0D%0A%0D%0AExample 1:%0D%0A%0D%0AInput: arr = %5B1,2,3%5D%0D%0AOutput: 2%0D%0AExplanation: 1 and 2 are counted cause 2 and 3 are in arr.%0D%0AExample 2:%0D%0A%0D%0AInput: arr = %5B1,1,3,3,5,5,7,7%5D%0D%0AOutput: 0%0D%0AExplanation: No numbers are counted, cause there's no 2, 4, 6, or 8 in arr.%0D%0AExample 3:%0D%0A%0D%0AInput: arr = %5B1,3,2,3,5,0%5D%0D%0AOutput: 3%0D%0AExplanation: 0, 1 and 2 are counted cause 1, 2 and 3 are in arr.%0D%0AExample 4:%0D%0A%0D%0AInput: arr = %5B1,1,2,2%5D%0D%0AOutput: 2%0D%0AExplanation: Two 1s are counted cause 2 is in arr.%0D%0A%22%22%22%0D%0A%0D%0Afrom collections import defaultdict%0D%0A%0D%0Aclass Solution:%0D%0A    def countElements(self, arr: List%5Bint%5D) -%3E int:%0D%0A        found = defaultdict(int)%0D%0A        count = 0%0D%0A        for elem in arr:%0D%0A            found%5Belem%5D += 1%0D%0A%0D%0A        for elem, n in found.items():%0D%0A            complement = elem + 1%0D%0A            if complement in found:%0D%0A                count += n%0D%0A        return count

ADd day7