Sponsored
Use these hints if you're stuck. Try solving on your own first.
Think on Dynamic Programming.
DP(pos, last) which means we are at the position pos having as last the last character seen.
Solve with full IDE support and test cases