Help Needed

Revision en2, by hello__world_, 2022-01-11 15:27:11

This question was asked in Infosys test (2022).

Wael has a sequence S. He found that the sub-sequences of S that are derived from S after deleting exactly two letters are considered as beautiful subsequences.

Given string S, your task is to find the number of different beautiful subsequences of S. Since the answer can be very large return it modulo 10^9 + 7.

Input Format:

The first line contains a string S, denoting the given sequence.

Constraints:

1 <= len(S) <= 10^6

Sample Input:

  1. aa --> 1 (The only beautiful sub-sequence is empty sequence)

  2. bccb --> 4 (we can get {bc,cb,cc,bb} so answer is 4)

  3. bbbbbb --> 1 (the only possible sub-sequence is bbbb, so answer is 1)

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English hello__world_ 2022-01-11 15:27:11 51 Tiny change: 'Wael has a' -> 'This question was asked in Infosys test (2022).\n\nWael has a'
en1 English hello__world_ 2022-01-11 14:06:58 703 Initial revision (published)