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
- 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
- Generate original array from difference between every two consecutive elements
- Replacing an element makes array elements consecutive
- Check if array elements are consecutive | Added Method 3
- Absolute Difference of all pairwise consecutive elements in an array
- 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
- 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)
- Count consecutive pairs of same elements
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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