Back to string manipulations for this one. Nice problem but I found the solution a little to simple compared to the last two problems, especially for the second part.

I solved the first part using a for loop inside a do-while loop to react all elements in the polymer until it couldn’t be reacted further. Using ASCII codes helps a lot in checking whether adjacent units are of the same type and polarized or not: Math.Abs(firstUnit - secondUnit) == 32.

The solution to the second part is basically given in the problem description: removing each possible unit, calculating the reactions and finding the smallest reacted polymer. It’s basically just 26 times the first part of the problem.