The TransCompilator

Solved LeetCode program · 982 of 1,000

#1358 · Number of Substrings Containing All Three Characters

Medium String chunk-20.md

Original English source

The text is "abcabc". The lastplaces is a list of 3 zeros. Set item 0 of lastplaces to -1. Set item 1 of lastplaces to -1. Set item 2 of lastplaces to -1. The answer is 0.
For every spot from 0 to the last position of text.
The symbol is character spot of text. If symbol is "a", set item 0 of lastplaces to spot. If symbol is "b", set item 1 of lastplaces to spot. If symbol is "c", set item 2 of lastplaces to spot.
If item 0 of lastplaces is at least 0 and item 1 of lastplaces is at least 0 and item 2 of lastplaces is at least 0.
The low is the smaller of item 0 of lastplaces and item 1 of lastplaces. The low is the smaller of low and item 2 of lastplaces. Increase answer by low plus 1.

Show answer.

Open in Playground Browse all 1,000 problems

Expected stdout

10