All Subset Sums

Programming Interview Hard 17 views
Back to Questions

Problem Description

Consider {x}. Use recursion function dfs(i,cur) to generate all subset sums. Output sums sorted.

Input Format

First line n. Second line n integers.

Output Format

All sums sorted space-separated.

Sample Test Case

Input:
3 1 2 3
Output:
0 1 2 3 3 4 5 6

Constraints

0

Solutions (0)

No solutions submitted yet. Be the first!

Discussion (0)

No comments yet. Start the discussion!

Prev Next