my code:- https://ide.codingblocks.com/s/292149
Segmentation Fault in recursion approach
use this base case
if(n == 0 || n==1)
return n;
because for n=1 it is oscillating between 0 and 1
if you have more doubts regarding this feel free to ask
i hope this helps
if yes hit a like and don’t forgot to mark doubt as resolved 
I am getting 3 for AAA and 64 for ABCDEFG, please check what I have done wrong
this is correct output
for aaa
The 3 distinct subsequences are “a”, “aa” and “aaa”
it also include the empty set and for ABCDEFG hacker blocks shows 128
hence multiply your ans with 2