Si my logic correct?

please check whether my logic is correct or not

Yes your logic is fine, but you are not returning from your function in the base case. Also since recursion takes exponential time your code will give TLE for larger cases. So, try to think of a faster way!

its just am filling my vector which is defined globally for now am trying the bruteforce way it must atleast run for smaller cases i tried printing in base case but for n=2 it only printing aa not the other one

please replyy am waiting

yes Hemant, this is because after line 10, you should add return; because otherwise it will keep running and won’t detect as a base case. See I edited your code as well.