Author |
Topic: Array conversion (Read 758 times) |
|
sateesp
Newbie


Gender: 
Posts: 35
|
 |
Array conversion
« on: Aug 29th, 2010, 5:56am » |
Quote Modify
|
Given an array B[] of size N, where each element in B[i] = A[i] + A[(i+1) %N]. Find the array A[] Example: Given B[] = {3,5,7,5} We need to print A[] = {1,2,3,4}
|
|
IP Logged |
|
|
|
towr
wu::riddles Moderator Uberpuzzler
    
 Some people are average, some are just mean.
Gender: 
Posts: 13730
|
 |
Re: Array conversion
« Reply #1 on: Aug 29th, 2010, 6:42am » |
Quote Modify
|
There are many possible such arrays if N is even. For example, [-1,4,1,6] would work just as well, or [13,-10,15,-8], or in general [1,2,3,4] + k*[-1,1,-1,1]. So for even N you can just start with A[0]=0, and work from there.
|
« Last Edit: Aug 29th, 2010, 6:45am by towr » |
IP Logged |
Wikipedia, Google, Mathworld, Integer sequence DB
|
|
|
|