Editorial for Another Contest 5 Problem 2 - Great Graffiti
Submitting an official solution before solving the problem yourself is a bannable offence.
The first observation to make here is that the answer is at most 3. This is
because we are guaranteed to start out with some letter in
DMOJ, and we
can always just add the three missing letters.
With this observation, there are two approaches. One is to enumerate all
scenarios where the answer is ~0~, ~1~, or ~2~ - these correspond respectively
to all subsequences of
DMOJ of length ~4~, ~3~, and ~2~. Another is to brute
force all possible ways of inserting 0 characters, 1 character, and 2