Answers for "program to calculate and return the sum of distance between the adjacent numbers in an array of positive integer java"

0

program to calculate and return the sum of distance between the adjacent numbers in an array of positive integer java

def findTotalSum(n,numbers,pos):
    total = 0
    for i in range(pos-1,n-1):
        total+= abs(numbers[i]-numbers[i+1])
    return total
n = int(input())
numbers = list(map(int, input().split()))
pos = int(input())
print(findTotalSum(n,numbers,pos))
Posted by: Guest on April-05-2021

Code answers related to "program to calculate and return the sum of distance between the adjacent numbers in an array of positive integer java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language