L1 and L2 are two lists which only consist of X's and Y's. L1 and L2 have the same length.
How many sublists of L1 contain the same number of X's as the sublist of L2 in the same position? The empty sublist is not counted.
For example:
L1=XL2=Y=> return0L1=Y, YL2=Y, Y=> return3L1=Y, X, YL2=X, Y, X=> return2L1=Y, Y, X, XL2=X, X, Y, Y=> return2
A brute-force approach would have time complexity O(n^2). I think (but I am not sure) there's an O(n) solution, but I can't put my finger on it.