Given a line from 0 to n points and starting point x and end point y and string which consists only "F" and "B"(F-forward and B-backward). I need to find all subsequence which can lead from starting point to end point.
For example: n=6, x=1, y=2 and String=FFBFBF answer is 7. because there are subsequences F, FFB, FBF,BFF,FFBFB,FBFBF,FFBBF which can lead us from 1 to 2.
I was thinking of find all subsequence and then find it's value assuming F=1 and B=-1, so I can get the how many unit I can move using subsequence. But can anyone suggests me if there is any better way to solve it better way in terms of Time complexity.