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: [1,2,3]
Output: 2
Hints
Related Problems

1426. Counting Elements

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