Question: Principal Global Services Coding Round OA | Array Pair Frequency Logic | Recent Online Assessment 2026 | Repeating Integer Pairs
0
Entering edit mode

Question: Repeating Integer Pairs

Problem Statement:

You are given a list of integers. Write a program which prints all the integer pairs in the list that repeat. If the list has more than one such pair, print all the pairs in consecutive lines in a sorted order. Sorting should be performed on the first integer of the pair.

Read the input from STDIN and print the output to STDOUT. Do not write arbitrary strings while reading the input or while printing, as these contribute to the standard output and test cases will fail.

Input Format:

  • First Line has an integer, N.
  • Second Line has N integers separated by single white spaces.

Output Format:

  • The integer pairs which repeat are printed one in each line, sorted in ascending order.

Constraints:

  • The list has at least one such integer pair.
  • The occurrences of the repetitions must always be distinct.

Sample Input 1:

5

1 2 3 1 2

Sample Output 1:

1 2

Explanation 1:

Since 1 2 is repeating in the list, it forms a couple. Hence the output is 1 2.

Login before adding your answer.

Similar Posts
Loading Similar Posts