8 lines scala solution
\nobject Solution {\n  import scala.math.Ordering.Implicits._\n  import scala.collection.immutable.TreeSet\n  def largestSquareArea(bottomLeft: Array[Array[Int]
```\nobject Solution {\n  import scala.math.Ordering.Implicits._\n  import scala.collection.immutable.TreeSet\n  def largestSquareArea(bottomLeft: Array[Array[Int]], topRight: Array[Array[Int]]): Long =\n    lazy val x0 = (bottomLeft.map(p=> p.head->p.last) zip topRight.map(p=> p.head->p.last)).to(TreeSet)\n    x0.iterator.flatMap{r0 => x0.iteratorFrom(r0).to(List).drop(1)\n      .takeWhile{r1 => (r0._2._1 > r1._1._1)}\n      .collect {case r1 if (r0._1._2 < r1._2._2) && (r0._2._2 > r1._1._2) => List(\n        (r0._2._1 min r1._2._1) - (r0._1._1 max r1._1._1),\n        (r0._2._2 min r1._2._2) - (r0._1._2 max r1._1._2)\n      ).map(_.abs).min}\n    }.maxOption.map(len => len.toLong * len).getOrElse(0L)\n}\n\n```
['Scala']