Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Subsequence Sum After Capping Elements

XPChallenge Points: 10
levelLevel: Easy

You are given an integer array nums of size n and a positive integer k.
An array is said to be capped by value x if every element in it is replaced by min(nums[i], x).
For each integer x in the range 1 to n, determine whether it is possible to select a subsequence from the array capped by x such that the sum of the selected elements equals k.
Return a 0-indexed boolean array answer of size n, where answer[i] is:
• true if it’s possible when using x = i + 1
• false otherwise.

Example 1:

Input: nums = [5, 2, 3, 6], k = 7

Output: [false, false, true, true]

Example 2:

Input: nums = [2, 4, 6, 8, 10], k = 6

Output: [true, true, true, true, true]

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result