Geeksforgeeks

Error

×

Leaderboard

Showing:

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

@Ibrahim Nash | 5725 |

@blackshadows | 5685 |

@akhayrutdinov | 5111 |

@mb1973 | 4989 |

@Quandray | 4908 |

@saiujwal13083 | 4156 |

@sanjay05 | 3762 |

@marius_valentin_dragoi | 3511 |

@sushant_a | 3453 |

@KshamaGupta | 3318 |

@the_coder95 | 3302 |

Complete Leaderboard | |

Handle | Score |

@avaiesshaik782 | 662 |

@arpitsatnalika | 629 |

@code_it_ | 591 |

@prakharxyz | 583 |

@tujhekya | 542 |

@Rahul Jadhav 1 | 458 |

@sivanandh03 | 448 |

@satyam0460 | 433 |

@imnm | 426 |

@iamronak | 424 |

@18eumc107 | 421 |

Complete Leaderboard |

Given an unsorted array **arr**[] of size **N** and that contains **even **number of occurrences for all numbers except two numbers. Find the two numbers in decreasing order which have odd occurrences.

**Note:** Expected O(n) time complexity and O(1) extra space.

**Input:**

The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case contains an integer N denoting the size of the array. Then the following line contains n space separated integers.

**Output:**

Print two space separated integers which have odd occurrences. Print the greater number first and then the smaller odd number.

**Constraints:**

1 <= T <= 100

2 <= N <= 10^{5}

1 <= arr[i] <= 10^{5}

**Example:**

**Input:**

2

8

4 2 4 5 2 3 3 1

6

1 7 5 5 4 4

**Output:**

5 1

7 1

**Explanation:**

**Testcase 1:** 5 and 1 are odd occurring elements in the array.

**Testcase 2:** 7 and 1 are odd occurring elements in the array.

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
Two numbers with odd occurrences

...