Javascript, One pass, RIP if you get this question in an interview
\nvar uniqueLetterString = function(s) {\n    let currentUniqueCount = 0;\n    let lastPositionSeen = new Map();\n    let contributions = new Map();\n    let an
```\nvar uniqueLetterString = function(s) {\n    let currentUniqueCount = 0;\n    let lastPositionSeen = new Map();\n    let contributions = new Map();\n    let answer = 0;\n    \n    for (let x = 0; x < s.length; x++) {\n        \n        const char = s[x];\n        const prevContributions = contributions.has(char) ? contributions.get(char) : 0;\n        const newContributions = x + 1 - (lastPositionSeen.has(char) ? lastPositionSeen.get(char) + 1 : 0);\n        \n        currentUniqueCount = currentUniqueCount - prevContributions + newContributions;\n        \n        contributions.set(char, newContributions);\n        lastPositionSeen.set(char, x);\n\n        answer += currentUniqueCount;\n    }\n    \n    return answer;\n};\n\n\n// ABCA\n\n// A        1                    A\n\n// AB      1 + 2             A, AB, B\n// B\n\n// ABC    3 + 3            A, AB, B, ACB, BC, C\n// BC\n// C\n\n// ABCA  6 + 4 - 2\n// BCA\n// CA\n// A\n```
['JavaScript']