Given an array print sum of the pairwise consecutive elements.
Input : 8, 5, 4, 3, 15, 20 Output : 13, 9, 7, 18, 35 Input : 5, 10, 15, 20 Output : 15, 25, 35
The solution is to traverse the array and saving the sum of consecutive numbers in the variable sum.
14 25 20 11
- Replace array elements by sum of next two consecutive elements
- Find elements of array using XOR of consecutive elements
- Construct an array from GCDs of consecutive elements in given array
- Product of all pairwise consecutive elements in an Array
- Modulus of all pairwise consecutive elements in an Array
- Number of ways an array can be filled with 0s and 1s such that no consecutive elements are 1
- Replacing an element makes array elements consecutive
- Absolute Difference of all pairwise consecutive elements in an array
- Generate original array from difference between every two consecutive elements
- Check if array elements are consecutive | Added Method 3
- Rearrange an array to minimize sum of product of consecutive pair elements
- Check if elements of an array can be arranged in a Circle with consecutive difference as 1
- Maximum number of consecutive 1's in binary representation of all the array elements
- Remove minimum elements from array such that no three consecutive element are either increasing or decreasing
- Check if array elements are consecutive in O(n) time and O(1) space (Handles Both Positive and negative numbers)
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : jit_t