Passes 6 test cases . fails 3. cant find the issue
i have a left and right pointer . if it is a cb number , i increase left pointer . if it is not i increase right pointer . and when right pointer reaches end of string but left is not at end of string , i increase left pointer and start again from right = left.
Hi @Anchal, pls try out a different approach for generating numbers. This one will not work. Since our goal is to generate out maximum numbers which are CB numbers.
Hint:
or number 123
numbers generated will be: 1, 2, 3, 12, 23, 123
Try to generate numbers in above fashion and then check for if it is a CB No. or not.
Also once you know that by using certain digits you have formed a CB number then pls keep a track wherein you can check which digit has been used and digit is available for use; when generating next number.
I hope this helps 