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
- Find elements of array using XOR of consecutive elements
- Replace array elements by sum of next two consecutive elements
- Construct an array from GCDs of consecutive elements in given array
- Modulus of all pairwise consecutive elements in an Array
- Product of all pairwise consecutive elements in an Array
- Generate original array from difference between every two consecutive elements
- Replacing an element makes array elements consecutive
- Number of ways an array can be filled with 0s and 1s such that no consecutive elements are 1
- Absolute Difference of all pairwise consecutive elements in an array
- Check if array elements are consecutive | Added Method 3
- Maximum number of consecutive 1's in binary representation of all the array elements
- Check if elements of an array can be arranged in a Circle with consecutive difference as 1
- Rearrange an array to minimize sum of product of consecutive pair 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