scala twoliner
scala\nobject Solution {\n  def minimumMoney(transactions: Array[Array[Int]]): Long =\n    lazy val (neg,pos) = transactions.toList.map(_.toList)\n      .partit
```scala\nobject Solution {\n  def minimumMoney(transactions: Array[Array[Int]]): Long =\n    lazy val (neg,pos) = transactions.toList.map(_.toList)\n      .partition(l => l.head > l.last)\n    List(neg.sortBy(_.last), pos.maxByOption(_.head)).flatten\n      .scanLeft((0L,0L)){ case((candidate,deficiency), l) =>\n        // lazy val (cost,cashback) = l.head -> l.last\n        // (b+cost, b+cost-cashback)\n        (deficiency + l.head, deficiency + l.head - l.last)\n      }.map(_._1).max\n}\n```
['Greedy', 'Sorting', 'Scala']