#3685

Subsequence Sum After Capping Elements

expert · 1160 · lc medium +32 · 25.1% accepted · 161 likes · top 4%

Description

Given an integer array nums of size n and a positive integer k, capping by x means replacing each element with min(element, x). For each x from 1 to n, check if some subsequence of the capped array sums to exactly k. Return a boolean array of size n where index i is true when x = i + 1 works.

Code

1
2
3