scala twoliner
scala []\nobject Solution {\n  def countWays(ranges: Array[Array[Int]]): Int =\n    lazy val len = (ranges.sortBy(a => (a.head, -a.last))\n      .foldLeft(List(
```scala []\nobject Solution {\n  def countWays(ranges: Array[Array[Int]]): Int =\n    lazy val len = (ranges.sortBy(a => (a.head, -a.last))\n      .foldLeft(List((-1,-1))){ case (l,a) =>\n        if(l.head._2 < a.head) (a.head, a.last) +: l\n        else (l.head._1, l.head._2 max a.last) +: l.tail\n      }.length - 1)\n    Iterator.range(0,len-1).foldLeft(2){case (acc,_) =>\n      (acc<<1)%1_000_000_007\n    }\n}\n```
['Greedy', 'Sorting', 'Scala']