Guest User

Untitled

a guest
Jun 18th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. import math._
  2. import scala.util._
  3.  
  4. /**
  5. * Auto-generated code below aims at helping you parse
  6. * the standard input according to the problem statement.
  7. **/
  8. object Solution extends App {
  9. val n = readInt
  10. val strengths = (1 to n).map(_ => readInt).sortWith(_ < _)
  11. val diffs = strengths.sliding(2).map(l => Math.abs(l(0) - l(1)))
  12.  
  13. println(diffs.reduceLeft(_ min _))
  14. }
Add Comment
Please, Sign In to add comment