I am able to figure out that 2 pointer approach using left and right will be helpful but afterwards i am thinking of brute force that converting every string to numbers one by one and then i can,t figure out
Can you tell me how to proceed on this one
According to the Problem the work is to find the Max CB numbers from the given number.
As to work on substrings of the given number, we will capture the element into the String instead of integer .
The number βnβ given is nothing to do with our approach(as we are working on String) but can be useful according to your approach.
Intuition to solve this problem:
Put loop on string that will give substring of every length.
create a function that will return true if the passed number is a CB number otherwise return false.
To put a check if the digit is already a part of the any other CB number, create an boolean array say, valid which store which digits till now has been a part of any other CB number.
Take a counter and increment if a CB number is found.
At the end print the count.
Reference Code
if you want to ask something about this feel free to ask
i hope this helps
if yes show your response with
and donβt forgot to mark doubt as resolved