Title: Happy to solve two problems in LeetCode Biweekly Contest 191

Revision en1, by MAxXter789123, 2026-09-12 20:00:53

Hi Codeforces community,

I solved two problems in LeetCode Biweekly Contest 191 using C++, finishing with a rank of 16,377 out of 35,500 participants and 7 points.

Here are my submissions:

  1. Count Values With Equally Spaced Occurrences I https://leetcode.com/submissions/detail/2139650243/

  2. Count Values With Equally Spaced Occurrences II https://leetcode.com/submissions/detail/2139689533/

My initial approach counted occurrences and used a set to check the gaps between their indices. It worked for the first problem, but repeated array scans caused TLE in the second.

Storing each number’s indices in a map of vectors helped avoid those repeated scans. I then checked consecutive gaps, stopping whenever the set contained two different values.

I thought using a set for the gap check was an interesting part of my approach, though I’m not sure how common it is. Would you use a set or simply compare every gap with the first one?

Happy to get both accepted. I’d appreciate feedback on my solutions and suggestions for making the code simpler.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English MAxXter789123 2026-09-12 20:00:53 1153 Initial revision (published)