Question: Better Together Twice Problem Statement In an array A containing N elements, each element is initially assigned its own value. Over time, the values evolve
Better Together Twice
Problem Statement
In an array A containing N elements, each element is initially assigned its own value. Over time, the values evolve such that nonzero elements increase the value of their adjacent elements by each day. Specifically, if the i th element holds a nonzero value, both the ith and ith elements if they exist increase by
The initial day is designated as day with subsequent days denoted as day day and so forth. The task is to compute the difference between the additon of values of all elements on day P and additon of values of all elements on day
Input Format
First line contains two integers N and P representing size of array and the Pth day.
Second line contains N integers value of each element on day
Output Format
A single integer representing the difference in the total sum of all elements between day P and day
Constraints
beginarrayl
N F
Ai
endarray
Sample Testcase
Testcase Input
Testcase Output
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
