In the problem CB Numbers my two test cases are not running properly. The code is attached below
Two test case are not running correctly
Your approach to the problem is wrong.
Instead of checking every substrings you need to try to maximize the count of valid substrings by firstly checking substrings of length 1, then of length 2 and so on.