@ishaanveerd,
Let’s say the string is abcd.
Now the result of this will be a + subsequences(bcd).
Answer of bcd will be b + subsequences(cd).
Answer of cd will be c + subsequences(d).
Answer of subsequences(d) will be d + subsequences(""), this is where we hit our base case and return arraylist with “” (empty string).
Now if we see our recursion stack the calls are from bottom to up (subseq(d), subseq(cd), subseq(bcd)…)
So now, the for loop will be executed 1 time for empty string arraylist [""].
2 times for arraylist ["",d]. 4 times for arraylist ["",d,c,cd]. 8 times for ["",d,c,cd,b,bd,bc,bcd].
And then finally 16 times for ‘a’.