Tap here to switch tabs
Problem
Submissions

Problem: Count Values With Equally Spaced Occurrences II

Count Values With Equally Spaced Occurrences II asks you to count distinct values in an integer array that appear at least three times with equal gaps between consecutive occurrences.

Statement

You are given an integer array nums.

A distinct value xx is called special if it satisfies both of the following conditions:

  • It appears at least 33 times in nums.

  • The difference between every pair of consecutive indices where xx appears is equal (the occurrence indices form an arithmetic sequence).

Return the number of distinct special values in nums.

Constraints:

  • 3≤3 \leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count Values With Equally Spaced Occurrences II

Count Values With Equally Spaced Occurrences II asks you to count distinct values in an integer array that appear at least three times with equal gaps between consecutive occurrences.

Statement

You are given an integer array nums.

A distinct value xx is called special if it satisfies both of the following conditions:

  • It appears at least 33 times in nums.

  • The difference between every pair of consecutive indices where xx appears is equal (the occurrence indices form an arithmetic sequence).

Return the number of distinct special values in nums.

Constraints:

  • 3≤3 \leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤109\leq 10^9