Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 5761 |

@blackshadows | 5701 |

@akhayrutdinov | 5111 |

@mb1973 | 4989 |

@Quandray | 4944 |

@saiujwal13083 | 4506 |

@sanjay05 | 3762 |

@marius_valentin_dragoi | 3516 |

@sushant_a | 3459 |

@verma_ji | 3341 |

@KshamaGupta | 3318 |

Complete Leaderboard | |

Handle | Score |

@aroranayan999 | 938 |

@bt8816103042 | 739 |

@SHOAIBVIJAPURE | 428 |

@codeantik | 412 |

@SherlockHolmes3 | 407 |

@neverevergiveup | 348 |

@mahlawatep | 347 |

@shalinibhataniya1097 | 343 |

@murarry3625 | 333 |

@saiujwal13083 | 326 |

@rohitanand | 314 |

Complete Leaderboard |

Given a set of integers, find distinct sum that can be generated from the subsets of the given sets.

**Example 1:**

**Input: **nums = {1,2}
**Output: **{1,2,3}
**Explanation: **Three distinict sum can be
calulated which are 1, 2 and 3.

**Example 2:**

**Input: **nums = {1,2,3}
**Output: **{1,2,3,4,5,6}
**Explanation: **Six distinict sum can be calculated
which are 1, 2, 3, 4, 5 and 6.

**Your Task:**

You don't need to read or print anything. Your task is to complete the function **DistinictSum() **which takes nums as input parameter and returns a list containing the distinict sum in increasing order,

**Expected Time Complexity: **O(n * sum) where sum = sum of all elements of nums.

**Expected Space Complexity: **O(n * sum)

**Constraints:**

1 <= length of nums <= 10^{2}

1 <= nums[i] <= 10^{2}

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes
Find all distinct subset (or subsequence) sums

...