Geeksforgeeks

Error

×

Leaderboard

Showing:

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

@Ibrahim Nash | 6560 |

@blackshadows | 6400 |

@mb1973 | 5777 |

@Quandray | 5275 |

@akhayrutdinov | 5111 |

@saiujwal13083 | 5074 |

@kirtidee18 | 4398 |

@sanjay05 | 3762 |

@mantu_singh | 3654 |

@gfgaccount | 3601 |

@marius_valentin_dragoi | 3525 |

Complete Leaderboard | |

Handle | Score |

@anish5256 | 991 |

@vimleshpratapsingh321 | 980 |

@skj7 | 899 |

@akhileshkumar562002 | 862 |

@kanewilliamson123 | 854 |

@pradeeppatidar1999 | 852 |

@pd420786 | 813 |

@infilooop | 800 |

@bunnybug320 | 796 |

@smitabose7826 | 784 |

@wallflowe101 | 778 |

Complete Leaderboard |

*As we mentioned earlier, bitwise operations can be used to find number of subsets. Here, we will use that.*

Given an array **A** of **N** elements. The task is to count all the **subsets **whose sum is **even**.

**Input Format:**

For each testcase, first line of input contains number of testcases **T**. For each testcase, there will be two lines, first of which containing N and next line contains N space seperated positive integers.

**Output Format:**

For each testcase, print the count of subsets whose sum of all elements is even.

**Constraints:**

1 <= T <= 100

1 <= N <= 10

1 <= A[i] <= 10

**User Task:**

Your task is to complete the function **countSumSubsets()** which counts all the subsets in which sum of all the elements is even.

**Example:
Input:**

1

3

1 2 3

**Output:**

3

**Explanation:
Testcase 1:** Three subsets are there whose sum of elements is even. Subsets are (3, 2, 1), (1, 3), (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?

YesLoading...

Even Subsets - Java

...