Hackerearth Palindrome substrings problem

LINK TO THE PROBLEM

I am using Recursion but not able to solve the problem fully. Can anyone tell me how to approach the problem.

Question-Explanation : 
We will be given a number N, We have to find the smallest  
lexicographically string S, which has N Palindromic sub-strings.
We have to print the length of that string.

Disclaimer : No Editorial is present on site. :sweat_smile: