通过精确删除2个字符来计算唯一子序列

问题陈述是这样的:

Shera挑选了一个随机字符串S,该字符串仅包含小写字母。现在,他 想要知道通过从中删除正好2个字符可以形成多少个不同的字符串 S. 你能帮忙吗?

O(n) Solution is required, i have followed the approach discussed here: Possibilities of removing two characters from string to get unique ones

但是在提交此方法后,仍然会有错误的答案。我找不到问题的确切点。

任何人都可以帮忙吗?