Question

link

Given a digit ‘3141592653’, find number of occurence of subsequence “123”. Note that the sequence occurs twice:

3141592653
 1    2  3
   1  2  3

Output 2.

Solution

Refer to [LeetCode 115] Distinct Subsequences.