Solved LeetCode program · 982 of 1,000
#1358 · Number of Substrings Containing All Three Characters
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.
Expected stdout
10