What is wrong in this code of CB numbers .Its giving 3 out 9 test cases wrong.
CB Numbers (3 out 9 test cases are wrong)
- 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.
refer to this here:
I have understood your approach but can its just the difference of loops.Can you tell me what is wrong in my loop part because from that also we are getting the substrings