#3509
Maximum Product of Subsequences With an Alternating Sum Equal to K
grandmaster · 2315 · lc hard +32 · 13% accepted · 57 likes · top 0%
Description
Find a non-empty subsequence of integer array nums whose alternating sum (even-indexed elements minus odd-indexed elements) equals k, and whose element product is maximized without exceeding limit.
Return that maximum product, or -1 if no valid subsequence exists.
Code
1
2
3