Let's say the given common ratio is 3 and the given list is:
For the given list, the possible geometric progression of size 3 with an index such that A*1 < A*2 < A*3 are:
( (index , number) , (index , number) , (index , number) )
So, the answer is 5.
r variables contains the list and the common ratio.
right dictionary are initialized to keeps track of how many times each number occurs to the left and right of each index in
3) While iterating through
mainl, we initiate each element in
right. Values in
left elements are initially 0 and
right elements are total number of occurrence of each element in
4) Count variable keep track of number of geometric progressions found.
5) While iterating through
mainl again , for each element
right[num]as the element cannot occur to the right of itself.
left[num/r]as GP can be written as a/n , a , a*n.
countas high*low is equal to number of geometric progression with that index as middle of the 3 element.
left[num]as the current element will occur to left of every next element.
6) We print
View all Courses