admin@onlinelearningcenter.in (+91) 7 999 01 02 03

WAP to Replace every array element by multiplication of previous and next

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: 
 
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
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.

Comments

Jquery Comments Plugin