In the finding CB numbers problems some of the test cases are failing. I have tried differnet custom inputs but not able to get what is the problem.
Here is my code: https://ide.codingblocks.com/s/191425
Test case fail (Finding CB numbers)
hey @Codecracaker532 your logic is slightly wrong you should for the smallest CB numbers first for example in the case of
1
23
your code gives the solution 1, but the answer is 2, 2 and 3 separately correct approach would be to check all the substrings of length 1 followed by length 2 and so on
I checked for 23, my code is giving 2 and 3 only. Please check if there is any other problem.
I have now changed the code to show the substrings selected as CB numbers. So you can check it yourself also. Please check if there is any other problem.
hey @Codecracaker532 your code’s solution for
1
23
is still 1, but should be 2. If the link to the updated code is different please provide me with the updated link as well.
I think it should be
2
23 but you are passing 1 23 as the length of string is 2
Here is the code which will give the selected substring
hey @Codecracaker532 my bad for providing the wrong input
8
86922395
In this case the correct solution is 2, 2, 3, 5 i.e 4 but your code is giving 692239, 5 i.e 2.you should first check all the substrings of length 1 and then of length 2 and so on.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.