I assumed the graph as a DAG and there are no additional spaces in the input.
Anyone could point out any flaws or critical inputs? The following is my algorithm:
Initially for all vertices with out-degree 0, give them count 1, and mark the all other vertices with count 0.
And repeat the following process while there is a vertex V with outdegree 0, for all its parents (vertices who has edges targetted to V), remove the edge between the parents and V. And increase each the parents' counts by (count of V).
So count of a vertex means how many ways are there starting from that vertex. I think it will produce same result with using DP with memoization.
So, after doing that for all paths, follow the path vertex-by-vertex. And for every vertex on the path: Add up all counts of vertices which the current vertex has edges to, and is less than the next vertex on the path.
(for example, if current vertex is A and A has edges to C, D, and E, and the next vertex on the path is E, counts of C and D are summed up)
(The summation of the counts) + 1 will be the number of the path..
I was very confident about it but I'm really confused.

Thanks in advance,