Skip to content

Latest commit

 

History

History

Replace Every Array Element

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Given an array of integers, update every element with multiplication of previous and next elements with following exceptions.

  • First element is replaced by multiplication of first and second.
  • Last element is replaced by multiplication of last and second last.
Input: arr[] = {2, 3, 4, 5, 6}
Output: arr[] = {6, 8, 15, 24, 30}