Skip to content

Latest commit

 

History

History

sum-of-differences-in-array

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Your task is to sum the differences between consecutive pairs in the array in descending order.

For example: sumOfDifferences([2, 1, 10]) Returns 9

Descending order: [10, 2, 1]

Sum: (10 - 2) + (2 - 1) = 8 + 1 = 9

If the array is empty or the array has only one element the result should be 0 (Nothing in Haskell).