scala foldLeft
scala []\nobject Solution {\n  val masks = 0 +: List.range(0,10).map(1 << _)\n  def longestAwesome(s: String): Int = s.iterator.map(_ - \'0\').zipWithIndex\n   
```scala []\nobject Solution {\n  val masks = 0 +: List.range(0,10).map(1 << _)\n  def longestAwesome(s: String): Int = s.iterator.map(_ - \'0\').zipWithIndex\n    .foldLeft((0,0,Map(0 -> -1))){case ((mx,xor,aMap),(c,i1)) =>\n      lazy val xor1 = xor ^ (1<<c)\n      lazy val bMap = aMap + (xor1 -> aMap.getOrElse(xor1,i1))\n      lazy val i0 = masks.iterator.flatMap(mask => bMap.get(xor1 ^ mask)).min\n      (mx max (i1-i0),xor1,bMap)\n  }._1\n}\n```
['Hash Table', 'String', 'Bit Manipulation', 'Prefix Sum', 'Scala']