MAxXter789123's blog

By MAxXter789123, history, 91 minute(s) ago, In English

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.

  • Vote: I like it
  • -8
  • Vote: I do not like it

»
84 minutes ago, hide # |
 
Vote: I like it +2 Vote: I do not like it

While I appreciate your determination, if everyone started writing such blogs about every contest Recent Actions would be filled with meaningless blogs.