Tap here to switch tabs
Problem
Submissions

Problem: Counting Elements

Counting Elements asks you to count every array occurrence whose value has a consecutive successor: another element equal to that value plus one. Duplicate values count separately.

Statement

Given an integer array arr, count the total number of elements x such that x + 1 is also present in arr.

If there are duplicate values in arr, each occurrence of x should be counted separately as long as x + 1 exists in arr.

Constraints:

  • 1≤1 \leq arr.length ≤1000\leq 1000

  • 0≤0 \leq arr[i] ≤1000\leq 1000

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Counting Elements

Counting Elements asks you to count every array occurrence whose value has a consecutive successor: another element equal to that value plus one. Duplicate values count separately.

Statement

Given an integer array arr, count the total number of elements x such that x + 1 is also present in arr.

If there are duplicate values in arr, each occurrence of x should be counted separately as long as x + 1 exists in arr.

Constraints:

  • 1≤1 \leq arr.length ≤1000\leq 1000

  • 0≤0 \leq arr[i] ≤1000\leq 1000