## Editorial for Valentine's Day '19 J3 - Love!

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.

Author: Rimuru

For of the points, we can, very easily, brute force the problem with nested for loops, the first loop representing a position of l, the second defining a position of o, the third loop as the position of v, and the last loop representing the position of a letter e. From there, we can iterate over all positions that have l, o, v, e, and keep track with a counter.

In the worst case where (3rd batch), we will have l's, o's, v's, and e's, so the answer will be:

Time complexity:

From here, there are actually ways to score of the points on this problem, but as one way (without the author's knowledge) was published here, we will go over the intended solution.

We can count the number of e's that are positioned in front of each v, the number of v's that are positioned in front of each o, and the number of o's that are positioned in front of each l, and track a total of this.

In total, this will take memory and a time complexity of , implying we loop backwards.

One other thing to watch out for is the last case, where there are l's, o's, etc., where . This is because the solution would be , which is far too large for the int data type. (Sorry about it everyone, it was funny to see people WA on it…)

Time complexity: