#3752
Lexicographically Smallest Negated Permutation that Sums to Target
expert · 1115 · lc medium +32 · 30.9% accepted · 65 likes · top 8%
Description
Given a positive integer n and an integer target, return the lexicographically smallest array of size n whose elements' absolute values form a permutation of 1 through n and that sums to target, or an empty array if none exists.
Code
1
2
3