Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Maintain a prefix sum for the frequencies of characters.
You can iterate over all substring then iterate over the alphabet and find which character appears most and which appears least using the prefix sum array