Back to problems

Minimum Insertions to Form Repeated abc Pattern

Algorithm · IBM · Easy

Requirements Input consists of a lowercase string named s. In one move, you may add any lowercase letter at any location. Return the fewest additions required so that s becomes a string matching the repeating pattern "abcabcabc...". The letters already in s must keep their relative ordering; neither removing nor changing an existing letter is permitted. Examples Add a before b and c after it, producing abc. Insert b between the two existing letters, resulting in abc.

Checking your access…