ALL GCD PAIR

Given an array of integers A of size N containing GCD of every possible pair of elements of another array.

Find and return the original numbers which are used to calculate the GCD array in any order.
For example, if original numbers are {2, 8, 10} then the given array will be {2, 2, 2, 2, 8, 2, 2, 2, 10}.



Input Format

The first and only argument given is the integer array A.

Output Format

Find and return the original numbers which are used to calculate the GCD array in any order.	

Constraints

1 <= N <= 10000
0 <= A[i] <= 100000

For Example

Input 1:
    A = [2, 2, 2, 2, 8, 2, 2, 2, 10]
    
Output 1:
    [2, 8, 10]

Input 2:
    A = [5 5 5 15 ]
Output 2:
    [5, 15]
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving ALL GCD PAIR on Interview Code Editor
Sign Up
to access hints and editorial solutions for ALL GCD PAIR

Discussion


Loading...
Click here to start solving coding interview questions