Https://ide.codingblocks.com/s/245267

Please check my code and correct it as I am failing 2 test cases

@kodivine0 hey instead of fixing the start of the CB number, fix the length, first find CB number of len 1 , then of len 2 then of len 3 and so on.


Here refer to this code.
If this resolves your doubt mark it as resolved.

Sir, I am not able to understand the code.

@kodivine0 We are making CB number of len 1 to n. For fixing the length we have outer loop.
Now once length is fixed we start making sub strings of len size, we first make substring from 0-len-1, len-2*len-1and so on. No we have helper functions that tell us whether this substring is a CB number, next helper function tells us that if any position is already used by previous number or not as we can use one position only once.
Now isCBNumber function is simple.
isvalid function takes a bitset array of size 17, start,end to check if any position is marked true or not between the given start and end.
Bitset is just a datatype like bool but it takes less memory we are making visited array of size 17 only because maximum size of string is 17.
Do a dry run once it will help you in understanding the code.
If this resolves your doubt mark it as resolved.

In 23 , should we count (2,3) as two coding block nos or 23 a single coding block no or both (2,3) and 23 as three coding block nos?

@kodivine0 You can count one position only once, so for 23 you can either count it as 23, or 2,3 but not in both ways.
Now as we want to mazimize the numbers of CB number, 2,3 is the right choice