adajahpickens6870 adajahpickens6870
  • 11-05-2022
  • Computers and Technology
contestada

Write a function solution that given an array a of n integers (between -100 and 100), returns the sign (-1,0,1) of product of all the numbers in the array multiplied

Respuesta :

YulTheNinja YulTheNinja
  • 17-05-2022

left[0]=a[0];

for(int i=1;i<=n-1;i++)

   left[i]=(left[i-1]*a[i])%M;

right[n-1]=a[n-1];

for(int i=n-2;i>=0;i--)

   right[i]=(right[i-1]*a[i])%M;

for query q

   if(q==0)

       return right[1]%M;

   if(q==n-1)

       return left[n-2]%M;

   return (left[q-1]*right[q+1])%M;

Answer Link

Otras preguntas

4. The area of a triangle is 48ft?. For number 4a-4d, select yes or no to tell if the dimensions could be the height and base of the triangle.4a h=6ft;b=8ft yes
Written by Alexander Hamilton the the merits of the Electoral College. THE mode of appointment of the Chief Magistrate of the United States is almost the only p
In what part of the atom do alpha or beta particles originate?
Anyone plsss helpppp
The fall of The Berlin Wall is associated with which of the following movements? A-spread of democratic ideas B-imperialism C-cultural divergence D-spread of c
4th task Help please
Why were beavers valuable during the westward expansion?
The picture below demonstrates which type of chromosome mutation?
Evaluate the expression x + 9 when x = 10
3x-2y=17 2x-2y=10 What’s the answer?