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,000wherenis 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
1since1 + 1exists in the list.2since2 + 1exists in the list.- Another
2.
Leave a comment