Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math._
- import scala.util._
- /**
- * Auto-generated code below aims at helping you parse
- * the standard input according to the problem statement.
- **/
- object Solution extends App {
- val n = readInt
- val strengths = (1 to n).map(_ => readInt).sortWith(_ < _)
- val diffs = strengths.sliding(2).map(l => Math.abs(l(0) - l(1)))
- println(diffs.reduceLeft(_ min _))
- }
Add Comment
Please, Sign In to add comment