DEV Community

Discussion on: Daily Coding Problem #2

Collapse
 
severinson profile image
Albin Severinson

Nice find :-)

For the first problem I'd loop over the array twice. The first time to compute the total product and the second time to fill in the output array, dividing out each element of the input array from the total product for the corresponding output element.

I'm guessing that your solution is for the follow-up question though :-). If you have logarithms you could use them to convert multiplication and division to addition and subtraction. This is a common trick when working over finite fields.