8 kyu

Sum of differences in array

13,015 of 27,661kamilalew

Description:

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

Example

[2, 1, 10]  -->  9

In 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, None in Rust).

Arrays
Fundamentals

Stats:

CreatedAug 15, 2018
PublishedAug 15, 2018
Warriors Trained50155
Total Skips2524
Total Code Submissions127134
Total Times Completed27661
JavaScript Completions13015
C++ Completions3836
Haskell Completions271
Java Completions3342
C Completions659
NASM Completions28
Ruby Completions379
C# Completions995
λ Calculus Completions9
Python Completions5177
Lua Completions135
Julia Completions39
Rust Completions376
TypeScript Completions430
Scala Completions27
Total Stars507
% of votes with a positive feedback rating90% of 2787
Total "Very Satisfied" Votes2302
Total "Somewhat Satisfied" Votes396
Total "Not Satisfied" Votes89
Total Rank Assessments12
Average Assessed Rank
7 kyu
Highest Assessed Rank
7 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • kamilalew Avatar
  • anter69 Avatar
  • Chrono79 Avatar
  • JohanWiltink Avatar
  • bmoney27 Avatar
  • jamad Avatar
  • a.kozhanov Avatar
  • Awesome A.D. Avatar
  • user6793616 Avatar
  • hobovsky Avatar
  • cliffstamp Avatar
  • uniapi Avatar
  • stellartux Avatar
  • Aizaz_Ahmad Avatar
  • user8436785 Avatar
  • ZywOo Avatar
  • ejini战神 Avatar
  • akar-0 Avatar
  • Kacarott Avatar
  • lachesism Avatar
  • KayleighWasTaken Avatar
Ad