The TransCompilator

Solved LeetCode program · 933 of 1,000

#1297 · Maximum Number of Occurrences of a Substring

Medium String chunk-19.md

Original English source

The source is "aababcaab". The maxletters is 2. The span is 3. The size is the number of characters in source. The last is size minus span. The best is 0.
For every spot from 0 to last.
The piece is the slice of source from spot to spot plus span. The letters is a list of 128 zeros. The distinct is 0.
For every offset from 0 to span minus 1.
The code is character (spot plus offset) of source. If item code of letters is 0, add 1 to distinct. Set item code of letters to 1.
If offset is span minus 1 and distinct is at most maxletters.
The matches is 0.
For every start from 0 to last.
The other is the slice of source from start to start plus span. If other matches piece, add 1 to matches. If matches is more than best, set best to matches.

Show best.

Open in Playground Browse all 1,000 problems

Expected stdout

2