Error
|
|
---|---|
@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 | |
|
|
@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 an array arr[] of integers and an integer sum, the task is to count all subsets of the given array with a sum equal to a given sum.
Note: Answer can be very large, so, output answer modulo 109+7
Example 1:
Input: N = 6, arr[] = {2, 3, 5, 6, 8, 10} sum = 10 Output: 3 Explanation: {2, 3, 5}, {2, 8}, {10}
Input: N = 5, arr[] = {1, 2, 3, 4, 5} sum = 10 Output: 3 Explanation: {1, 2, 3, 4}, {1, 4, 5}, {2, 3, 5}
perfectSum
() which takes N, array arr[] and sum as input parameters and returns an integer valueWe strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?
Yes