Your Dashboard
Interview Coaching
Learn
System Design
ML System Design
Code
Behavioral
Salary Negotiation
Interview Guides
Search
⌘K
Get Premium
Leetcode 2389. Longest Subsequence With Limited Sum
For each query, determine the maximum number of elements you can pick from nums (as a subsequence) whose sum is ≤ query — equivalent to choosing as many smallest elements as possible. Sort nums, build prefix sums, and for each query use binary search (or scan) on the prefix sums to get the count.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
All Regions
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.