Python, not brute force, O(log n)
\n         a, b = 0, 0\n        \n        rest = n % 10\n        power = 1\n        \n        while n > 1:\n            n = n // 10 \n            if rest > 1:\n
```\n         a, b = 0, 0\n        \n        rest = n % 10\n        power = 1\n        \n        while n > 1:\n            n = n // 10 \n            if rest > 1:\n                a += 1*power\n                b += (rest - 1)*power\n            else:\n                a += (rest+1)*power\n                b += 9*power\n                n -= 1\n            rest = n % 10 \n            power *= 10\n                        \n        if n == 1:\n            a += power\n        \n        return [a, b]\n```
[]