Count Next Element
Given a list of integers nums
, return the number of elements x
there are such that x + 1
exists as well.
Constraints
n ≤ 100,000
wheren
is the length ofnums
https://binarysearch.com/problems/Count-Next-Element
Examples
Example 1
Input
- nums =
[3, 1, 2, 2, 7]
Output
- answer =
3
Explanation
We can take
1
since1 + 1
exists in the list.2
since2 + 1
exists in the list.- Another
2
.
Leave a comment