Page 1 of 1

data structure

Posted: Wed Mar 30, 2022 9:28 am
by answerhappygod
data structure
Data Structure 1
Data Structure 1 (28.1 KiB) Viewed 28 times
Write a complete Java program that provides a method named subtractPairs() that takes any array of integers as a parameter, replaces every 2 consecutive elements (starting from the right) with their difference and returns the array containing the sum values only. Assume number of elements is always even. Sample Output: Before: Left [5, 6, 6, 3, 3, 2, 2, 1)right After: Left[-1, -3, -1, -1]right Array size and elements should be read from the user.