Editorial for THICC '17 P5 - Smarties
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
For of points, one can iterate through all subarrays, and count how many of them have at least distinct elements.
Time Complexity: or
For the remaining of points, we can employ a two pointer approach. Let there be two pointers, and such that have elements. This can be achieved using a counter array. Implementation is left to the reader as an exercise.
Time Complexity:
Comments