Tap here to switch tabs
Problem
Submissions

Problem: Counting Elements

med
30 min
Try to solve the Counting Elements problem.

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

med
30 min
Try to solve the Counting Elements problem.

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