Scala DP with PriorityQueue
\nimport scala.collection.mutable\n\nobject Solution {\n    def maxTaxiEarnings(n: Int, rides: Array[Array[Int]]): Long = {\n      val ridesByEnd = mutable.Prio
```\nimport scala.collection.mutable\n\nobject Solution {\n    def maxTaxiEarnings(n: Int, rides: Array[Array[Int]]): Long = {\n      val ridesByEnd = mutable.PriorityQueue.from(rides)(\n        Ordering.by((item: Array[Int]) => item(1)).reverse\n      )\n      val maxAtPoint = Array.fill(n+1)(0L)\n      (1 to n).foreach {\n        v =>\n          while(ridesByEnd.nonEmpty && ridesByEnd.head(1) == v) {\n            ridesByEnd.dequeue() match {\n              case Array(start, end, tip) =>\n                val value = (end - start + tip)\n                maxAtPoint(end) =\n                // either continue prev ride or start one of new rides\n                  (value + maxAtPoint(start)) max maxAtPoint(end)\n            }\n          }\n          maxAtPoint(v) = maxAtPoint(v - 1) max maxAtPoint(v)\n      }\n      maxAtPoint(n)\n    }\n  }\n  ```
['Scala']