The repository that contains all solutions made for the course Competitive Programming and Contests by the University of Pisa
Solved | Solution | Time |
---|---|---|
Prefix Sum | 184 ms |
The solution uses the prefix sum technique to resolve the problem, in particular, it split the string into characters and create and intermedia vector that in position i has 1 if the string in position i-1 usi qual to the string in position i. Otherwise 0.
After that, a prefix sum operation is performed on the intermedia vector, and the query is performed on the prefix sum result.
The time and space complexity of the solution is O(N).