Given an array of integers, update every element with multiplication of previous and next elements with following exceptions.
a) First element is replaced by multiplication of first and second.
b) Last element is replaced by multiplication of last and second last.
Example:
a) First element is replaced by multiplication of first and second.
b) Last element is replaced by multiplication of last and second last.
Example:
Input: arr[] = {2, 3, 4, 5, 6} Output: arr[] = {6, 8, 15, 24, 30} // We get the above output using following // arr[] = {2*3, 2*4, 3*5, 4*6, 5*6}
Published By : Shazia Irfan Bebal