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

Find the value of 9x + 4y when x = 4 and y=-5
Prove that the difference between a two-digit number and the product of its digits will always be a 2 digit number.
What single percentage change is equivalent to a 12% increase followed by a 14% decrease?
I don’t know you can help me pleaseeeeee
Name of the group that has many members who had governed Vajji. A. Sangha B. o Gana C. O Sabha D. O Nagaram get confirm branliest to answer right​
in the 19th century why did they think that voting would cause infertility in women.
Please help asap! I on;y have 10 mins left!!!
discuss the negative impact of piracy on business
Read MENU 5 of 5 < HOME NOTES GLOSSARY PRINT Knowledge mignorawus to the susp designed to evoke recues 2010 Jupitermages Corporation Assessment Instructions
please help :( I really need the answers for tomorrow​