Comments

problem D can be solved for O(n)