We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
objectSolution{defsolve(n:Int,input:Seq[Int]):Unit={implicitvalorderingIntSeq:Ordering[Seq[Int]]=(lsa:Seq[Int],lsb:Seq[Int])=>implicitly[Ordering[Int]].compare(lsa.head,lsb.head)println(input.grouped(2).toList.groupBy(_.head).filter(_._2.length==n).view.mapValues(_.minBy(_.tail)).toMap.values.toList.sortBy(_.head).map(_.mkString(" ")).reduce(_+" "+_))}defapply():Unit={valN:Int=io.StdIn.readLine().trim.toIntvalinputList:Seq[Int]=(1toN).flatMap{_=>valinput:Array[Int]=io.StdIn.readLine().trim.split(" ").map(_.toInt)input}solve(N,inputList)}defmain(args:Array[String]){/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution*/Solution.apply()}}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Lists and GCD
You are viewing a single comment's thread. Return to all comments →