X

DAYS

:

HOUR

:

MINS

:

SEC

Copied to Clipboard
Longest Geometric Progression
Easy Accuracy: 8.62% Submissions: 116 Points: 2

Given a set of numbers, find the Length of the Longest Geometrix Progression (LLGP) in it. The common ratio of GP must be an integer.


Example 1:

Input:
N = 3
arr = {2, 4, 3}
Output: 2
Explaination: The longest geometric
progression is {2, 4}.


Example 2:

Input:
N = 6
Arr = {5, 7, 15, 10, 20, 29}
Output: 3
Explaination: The longest geometric 
progression is {5, 10, 20}.


Your Task:
You don't need to read input or print anything. Your task is to complete the function lenOfLongestGP() which takes the array arr[] and its size as input parameters and returns the Length of the Longest Geometrix Progression (LLGP).


Expected Time Complexity: O(N2)
Expected Auxiliary Space: O(N2)


Constraints:
1 ≤ N ≤ 100

1 ≤ arr[i] ≤ 100

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

Longest Geometric Progression

Output Window