Skip to content

Instantly share code, notes, and snippets.

@jackliusr
Last active August 29, 2015 14:04
Show Gist options
  • Save jackliusr/7c8918e2bd80c1d7e779 to your computer and use it in GitHub Desktop.
Save jackliusr/7c8918e2bd80c1d7e779 to your computer and use it in GitHub Desktop.
Hackerrank Service Lane in Scala
object Solution {
def main(args: Array[String]) {
val lines = io.Source.stdin.getLines().toList
val segs = lines(1).split("\\s+").map(_.toInt)
val testcases = lines.drop(2)
for( tc <- testcases){
val p = tc.split("\\s+").map(_.toInt).toList
println(segs.slice(p(0), p(1) + 1).min)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment