You are viewing a single comment's thread. Return to all comments →
def equalStacks(h1: Array[Int], h2: Array[Int], h3: Array[Int]): Int = List(h1,h2,h3).zipWithIndex.map { case (stack,id) => { stack.scanRight(0)(_+_).map{(_,id)}}} .flatten.groupBy{_._1}.values.filter{_.size==3}.toList .sortBy{case (List(a,b,c))=>(c)} .filter{case (List(a,b,c))=>(a._2==0 && b._2==1 && c._2==2)} .flatten.last._1
Seems like cookies are disabled on this browser, please enable them to open this website
Equal Stacks
You are viewing a single comment's thread. Return to all comments →