[Kotlin] O(n) Time and O(1) Space Solution
\nclass Solution {\n    fun numberOfUniqueGoodSubsequences(binary: String): Int {\n        val mod = 1000000007L\n        var res = 0L\n        val positions = 
```\nclass Solution {\n    fun numberOfUniqueGoodSubsequences(binary: String): Int {\n        val mod = 1000000007L\n        var res = 0L\n        val positions = arrayOf(0L, 1L)\n        binary.forEach {\n            val bit = it - \'0\'\n            val other = (bit + 1) % 2\n            res = (res + positions[bit]) % mod\n            positions[other] = (positions[other] + positions[bit]) % mod\n        }\n        if (binary.contains(\'0\')) {\n            ++res\n        }\n        return res.toInt()\n    }\n}\n```
[]