Best Subsequence

                                  Best Subsequence


You are given an array of length N.
- A subsequence is a sequence that can be derived from another sequence by deleting 
some elements without changing the order of the remaining elements.
You know that a subsequence is best if the sum of the elements of the subsequence is 
odd and maximum among all such subsequences.
It is guaranteed that this array contains at least one subsequence with odd sum.
Your task is to find the sum of the elements of the best subsequence.
Input format

- First line of input contains 
denoting number of test cases. 

- First line of each test case contains N, the size of the array.
. Second line of each test case contains 
N space-separated integers.

Output format
Print the expected answer for each test case in a new line.

Sample Input
-2 2 1 -3
-3 -10 2
Sample Output
Subsequence for 1st test case is [2,1].
Subsequence for 
2nd test case is [−3,2].
Note: Your code should be able to convert the sample input into the sample output. However, this is not enough to pass the challenge, because the code will be run on multiple test cases. Therefore, your code must solve this problem statement.


#include <bits/stdc++.h>
using namespace std;
int main()
    int n,ele,i,j,k;
    int arr[100000];
    int maxe=-100000,maxo=-100000;
     return 0;


Please do comment If u have any Queries!
One Comment

Add a Comment

Your email address will not be published. Required fields are marked *