Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
edited body; edited tags
Source Link
xskxzr
  • 7.6k
  • 5
  • 23
  • 47

Given an array of size $n$, we have to find the maximum number of multiples of $A[i]$ in the array, where the indexes of the multiples should be less than $i$.

For example, given the array

36 40 16 24 27 12 9 4

weWe see that element 4 has the highest number of multiples (5) as per the given conditions, so the answer is 5.

My approach: I used brute force to solve this. I used nested loops to solve this. The first loop from the last element and the second loop from the first element to the second to last element.

Can you help me improve the running time?

Given an array of size $n$, we have to find the maximum number of multiples of $A[i]$ in the array, where the indexes of the multiples should be less than $i$.

For example, given the array

36 40 16 24 27 12 9 4

we see that element 4 has the highest number of multiples (5) as per the given conditions, so the answer is 5.

My approach: I used brute force to solve this. I used nested loops to solve this. The first loop from the last element and the second loop from the first element to the second to last element.

Can you help me improve the running time?

Given an array of size $n$, we have to find the maximum number of multiples of $A[i]$ in the array, where the indexes of the multiples should be less than $i$.

For example, given the array

36 40 16 24 27 12 9 4

We see that element 4 has the highest number of multiples (5) as per the given conditions, so the answer is 5.

My approach: I used brute force to solve this. I used nested loops to solve this. The first loop from the last element and the second loop from the first element to the second to last element.

Can you help me improve the running time?

Bumped by Community user
Bumped by Community user
added 20 characters in body; edited tags; edited title
Source Link
Yuval Filmus
  • 279.1k
  • 27
  • 316
  • 512

maximum Maximum number of multiples of A[i] in thean array where the indexes of the multiples should be less than i(i.e j<i)element preceding it

givenGiven an array of size n...we$n$, we have to find the maximum number of multiples of A[i]$A[i]$ in the array, where the indexes of the multiples should be less than i(i.e j<i) e$i$.g:-given

For example, given the array:-36 40 16 24 27 12 9 4 we

36 40 16 24 27 12 9 4

we see that element 4 has the highest number of multiples  (5) as per the given conditions,so so the answer is 5.

My approach:-i I used bruteforcebrute force to solve this...i I used nested loops to solve this...the The first loop from the last element and the second loop from the first element to the second to last element.

I am unable to optimise it...need someCan you help me improve the running time?

maximum number of multiples of A[i] in the array where the indexes of the multiples should be less than i(i.e j<i)

given an array of size n...we have to find the maximum number of multiples of A[i] in the array where the indexes of the multiples should be less than i(i.e j<i) e.g:-given array:-36 40 16 24 27 12 9 4 we see that element 4 has the highest number of multiples(5) as per the given conditions,so the answer is 5

My approach:-i used bruteforce to solve this...i used nested loops to solve this...the first loop from the last element and the second loop from the first element to the second last element

I am unable to optimise it...need some help

Maximum number of multiples of an array element preceding it

Given an array of size $n$, we have to find the maximum number of multiples of $A[i]$ in the array, where the indexes of the multiples should be less than $i$.

For example, given the array

36 40 16 24 27 12 9 4

we see that element 4 has the highest number of multiples  (5) as per the given conditions, so the answer is 5.

My approach: I used brute force to solve this. I used nested loops to solve this. The first loop from the last element and the second loop from the first element to the second to last element.

Can you help me improve the running time?

Source Link

maximum number of multiples of A[i] in the array where the indexes of the multiples should be less than i(i.e j<i)

given an array of size n...we have to find the maximum number of multiples of A[i] in the array where the indexes of the multiples should be less than i(i.e j<i) e.g:-given array:-36 40 16 24 27 12 9 4 we see that element 4 has the highest number of multiples(5) as per the given conditions,so the answer is 5

My approach:-i used bruteforce to solve this...i used nested loops to solve this...the first loop from the last element and the second loop from the first element to the second last element

I am unable to optimise it...need some help