← All problemsSign in

3712. Sum of Elements With Frequency Divisible by K

LeetCodeArrayHash TableCountingOpen on judge ↗

You are given an integer array nums and an integer k. Return an integer denoting the sum of all elements in nums whose frequency is divisible by k, or 0 if there are no such elements. Note: An element is included in the sum exactly as many times as it appears in the array if its total frequency is divisible by k. Example 1: Input: nums = [1,2,2,3,3,3,3,4], k = 2 Output: 16 Explanation: -

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start