You are viewing a single comment's thread. Return to all comments →
def gridlandMetro(n: Int, m: Int, k: Int, track: Array[Array[Int]]): Long = { var ans = 1L * n*m track.groupBy(_(0)).values.foreach{ x => x.sortInPlaceBy{_(1)} var (l,r) = (x.head(1), x.head(2)) x.tail.foreach { t => (t(1),t(2)) match { case (a,b) if a > r => ans -= (r - l + 1) l = a r = b case (_,b) => r = r.max(b) } } ans -= (r - l + 1) } ans }
Seems like cookies are disabled on this browser, please enable them to open this website
Gridland Metro
You are viewing a single comment's thread. Return to all comments →