0931-0940

931. Minimum Falling Path Sum $\star\star$

932. Beautiful Array $\star\star$

933. Number of Recent Calls $\star$

934. Shortest Bridge $\star\star$

935. Knight Dialer $\star\star$

936. Stamping The Sequence $\star\star\star$

937. Reorder Data in Log Files $\star$

938. Range Sum of BST $\star$

939. Minimum Area Rectangle $\star\star$

940. Distinct Subsequences II $\star\star\star$

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
class Solution {
 public:
  int distinctSubseqII(string S) {
    vector<long> map(26);

    for (char c : S)
      map[c - 'a'] = accumulate(map.begin(), map.end(), 1L) % int(1e9 + 7);

    return accumulate(map.begin(), map.end(), 0L) % int(1e9 + 7);
  }
};