easy typescript solution
IntuitionApproachComplexity
Time complexity:
o(n)
Space complexity:
o(1)
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
o(n) 
- Space complexity:
o(1)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```typescript []
function numberOfSubstrings(s: string): number {
    const lastIndex = { a: -1, b: -1, c: -1 };
    let count = 0;
    for (let right = 0; right < s.length; right++) {
        lastIndex[s[right] as keyof typeof lastIndex] = right;
        const minIndex = Math.min(lastIndex.a, lastIndex.b, lastIndex.c);
        count += minIndex + 1;
    };
    return count;
}

```
['TypeScript']