Skip to content

2026-06-11 [Retry][3318] Find X-Sum of All K-Long Subarrays I (Easy) #6

Description

@zerexei

Date (attemp history: use title to fill)

2026-06-05 [Retry][3318] Find X-Sum of All K-Long Subarrays I (Easy) - solved w/out hints but got confused with sorted(key=)

Retry Date

2026-06-11

Difficulty

Easy

Pattern

Sliding Window + Frequency Counting + Custom Sorting

Core Idea

For each subarray of length k, count the frequency of every element. Rank elements by frequency in descending order, breaking ties by larger value. Keep only the top x distinct elements and compute the sum of all their occurrences.

Because the constraints are small, rebuilding the frequency map for every window is efficient enough.

Repo Link

https://github.com/zerexei/software-engineering/blob/main/datastructure-and-algorithm/sliding-window/Gjoe-Y-Tvn-pg-Bmm-L-Mpoh-Tvcbssbzt-J.md

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions