1426. Counting Elements

Problem

Count elements where x+1 also exists in the array.

Given an integer array arr, count how many elements x such that x + 1 also exists in the array.

Examples
Input: [0,1,1,4]
Output: 1
Hints
Related Problems

1426. Counting Elements

Count elements where x+1 also exists in the array.