Kindly find the error in the code.
One out of 8 testcase not passing
your code has two problems:
- there is no need of outer loop. your two inner loops are sufficient. since the solutions must not be overlapping.
- we need to find max no of solutions. but your approach wont do it. since you are generating substring based on start character(first all the substrings starting with first character, then with second character, so on…), it will find solution in any order and will have problem in cases like 137. it will give you count=1 , but 137 has two primes 3 and 7.
right approach: you must generate substring prioritized with length(all substrings with length 1, then length 2, so on…)
thanks
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.