Sponsored
Use these hints if you're stuck. Try solving on your own first.
For a given element x, how can you quickly check if x - 1 and x + 1 are present in the array without reiterating through the entire array?
Use a set or a hash map.
Solve with full IDE support and test cases