Search
⌘K

Leetcode 1838. Frequency of the Most Frequent Element

Given you can spend up to k unit increments to raise elements, maximize how many elements can be made equal by choosing a target value and increasing smaller elements to it; after sorting, this becomes finding the longest window where the cost to raise all values to the window's max is ≤ k. The typical solution uses a two-pointer/sliding-window check (with running sums) to test feasibility efficiently.

Asked at:

Meta


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Early December, 2025

Meta

Mid-level

Comments

Your account is free and you can post anonymously if you choose.