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 |

*Pairs and vectors can be used together to achieve some amazing results.* Here we will learn to use a vector that holds pairs.

You are given a **vector V of size n**. The vector hold pair of integers. Example V={(1,2),(3,4)...}. Now, you need to sum the second elements.

**Input Format:**

The first line of input contains **T** denoting the number of testcases. T testcases follow. Each testcase contains two lines of input. The first line contains n denoting the size of the array. The second line contains **2*n** elements.

**Output Format:**

For each testcase, in a new line, print the required output.

**Your Task:**

Since this is a function problem, you don't need to take any input. Just complete the provided function **sum()**.

**Constraints:**

1 <= T <= 100

1 <= n <= 10^{7}

0 <= V_{i }<= 10^{7}

**Examples:
Input:**

1

5

1 2 3 4 5 6 7 8 9 10

30

**Explanation:
Testcase1:**

v[0]= 1,2

v[1]= 3,4

v[2]= 5,6

v[3]= 7,8

v[4]= 9,10

Now we sum all the second elements of a pair. So 2+4+6+8+10=30

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
Pair Sum in Vector

...