scala solution
\n  def numberOfUniqueGoodSubsequences(binary: String): Int = {\n    val mod = 1000000007\n    val res = binary.foldLeft((0, 0, 0))((ans, cur)=>{\n      if(cur 
```\n  def numberOfUniqueGoodSubsequences(binary: String): Int = {\n    val mod = 1000000007\n    val res = binary.foldLeft((0, 0, 0))((ans, cur)=>{\n      if(cur == \'1\') (ans._1, (ans._2 + ans._1 + 1) % mod, ans._3)\n      else ((ans._1 + ans._2) % mod, ans._2, 1)\n    })\n    (res._2 + res._1 + res._3) % mod\n  }\n```
['Scala']