How should one approach this problem? Should I like generate all the substrings and then check all of them if they are a cb number? Or there is some other better way to do this?
How to approach this problem
Hey Shubham!
Yes you’re thinking in the right direction, you have to generate substring of every length. THen create a bool function that will return true if the passed number is a CB number otherwise return false.
I tried that and as given in question we need to eliminate the string that has already occurred and is cb number. I did that. Still some test cases are failing. Please help me out. Here’s the link to my code: https://ide.codingblocks.com/s/111079
Please check the comments in the following code