8 kyu

Sum of differences in array

13,243 of 28,617kamilalew

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 Trained51559
Total Skips2599
Total Code Submissions130355
Total Times Completed28617
JavaScript Completions13243
C++ Completions4125
Haskell Completions276
Java Completions3410
C Completions678
NASM Completions29
Ruby Completions383
C# Completions1048
λ Calculus Completions10
Python Completions5441
Lua Completions139
Julia Completions40
Rust Completions403
TypeScript Completions460
Scala Completions28
Total Stars518
% of votes with a positive feedback rating90% of 2839
Total "Very Satisfied" Votes2350
Total "Somewhat Satisfied" Votes400
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