Replace element(Contest)
Replace element easy Time Limit: 2 sec Memory Limit: 128000 kB
Last updated
Replace element easy Time Limit: 2 sec Memory Limit: 128000 kB
Last updated
Problem Statement :
Given an array of N elements, your task is to 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.
See example for more clarity Input First line of input contains the size of array N, next line contains N space separated integers denoting values of array.
Constraints:- 2 < = N < = 100000 1 < = arr[i] < = 100000 Output Print the modified array Example Sample Input :- 5 2 3 4 5 6
Sample Output:- 6 8 15 24 30
Explanation:- {23, 24, 35, 46, 5*6}
Sample Input:- 2 3 4
Sample Output:- 12 12
link: