Tap here to switch tabs
Problem
Submissions

Problem: Find Array Given Subset Sums

Find Array Given Subset Sums provides all subset sums of an unknown integer array in arbitrary order. Reconstruct and return any array that matches them, including negative values.

Statement

You are given an integer n representing the length of an unknown integer array ans. You are also given an integer array sums of size 2‘n‘2^{`n`}, which contains the sums of all 2‘n‘2^{`n`} subsets of ans in no particular order.

Return the array ans. If multiple valid answers exist, return any of them.

Note: The sum of the elements in an empty subset is considered to be 00.

Constraints:

  • 1≤1 \leq n ≤15\leq 15

  • sums.length =2‘n‘= 2^{`n`}

  • −104≤-10^4 \leq sums[i] ≤104\leq 10^4

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Find Array Given Subset Sums

Find Array Given Subset Sums provides all subset sums of an unknown integer array in arbitrary order. Reconstruct and return any array that matches them, including negative values.

Statement

You are given an integer n representing the length of an unknown integer array ans. You are also given an integer array sums of size 2‘n‘2^{`n`}, which contains the sums of all 2‘n‘2^{`n`} subsets of ans in no particular order.

Return the array ans. If multiple valid answers exist, return any of them.

Note: The sum of the elements in an empty subset is considered to be 00.

Constraints:

  • 1≤1 \leq n ≤15\leq 15

  • sums.length =2‘n‘= 2^{`n`}

  • −104≤-10^4 \leq sums[i] ≤104\leq 10^4