You are viewing a single comment's thread. Return to all comments →
A scala solution: the idea is to compare the number of distinct pairs with the number of distinct x's
object Solution { def main(args: Array[String]): Unit = { val read = () => scala.io.StdIn.readLine for (_ <- 1 to read().toInt) { val pairList = (1 to read().toInt).map(_ => read().split(" ").map(_.toInt)) val numOfX = pairList.map(_(0)).toSet.size val numOfPair = pairList.toSet.size if (numOfX == numOfPair) println("YES") else println("NO") } } }
Seems like cookies are disabled on this browser, please enable them to open this website
Functions or Not?
You are viewing a single comment's thread. Return to all comments →
A scala solution: the idea is to compare the number of distinct pairs with the number of distinct x's