Code is working but extra substring are also counted

In 4991, both 499 and 991 are CB numbers but you can choose either 499 or 991, not both…how to include this restriction in the code…

Hi Akshay,
See to check if the digit is already a part of the any other CB number, you can create an boolean array say, valid which store which digits till now has been a part of any other CB number.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.