4 lines of scala with span and fold
scala\n  def insert(intervals: Array[Array[Int]], newInterval: Array[Int]): Array[Array[Int]] = {\n    lazy val (begin,next) = intervals.span(_ (1) < newInterva
```scala\n  def insert(intervals: Array[Array[Int]], newInterval: Array[Int]): Array[Array[Int]] = {\n    lazy val (begin,next) = intervals.span(_ (1) < newInterval(0))\n    lazy val (mid,end) = next.span(_ (0) <= newInterval(1))\n    lazy val im = mid.foldLeft(newInterval){case (Array(a1,a2),Array(i1,i2)) => Array(a1 min i1, a2 max i2)}\n    begin ++ Array(im) ++ end\n  }\n```
['Scala']