i understand the problem but its difficult to get the approach
the approach i make dont know its right or wrong
for ex the string is 81615
maine ye socha ki first i check for individual substring of size 1 i.6 8 ,1, 6, 1, 5 then i go for 81,16,61,5 to convert the string into integer and check from the array ki cb number hein ki ni
something like this but does not find the way
pls help me to give the approach also is my approach is correct
Finding CB numbers doubt problem
one more doubt i have suppose just for example i say if 81 is my cb number 16 ko cb number le sakte hein kya kyuki 1 to use hoogaya tooo nhi lesakte hein i guess according to question correct me if i am wrong just for example i ask this question to clear my doubt
yes this is correct
u should first mark all 1 length CB number and then 2 and then 3 so on. because we want to maximize it.
Approach
-
check for all substrings of the given strings of digit ,starting from len 1
a) check if substring is CB number or not , for this you can create a function (is_cb_number)
b) now if it is a substring => call a function that marks the index as visited for indices which are part of that CB number
c) increment the count of CB number -
print the Count
is_cb_number function
simple checks that are given in the questions
a CB number is need not to be a prime number. (Generally misinterpreted)
Reference Code
yes you can’t use a digit twice
if you have consider 81 as CB number then 16 can’t
to handle this i have used visited array which marks the index of the digits which are already considered