LOL
InterviewTime limit1sMemory limit256 MB
Find the fewest insertions, replacements, and deletions that make each given word contain lol as a contiguous substring.
- Level
Easy3 of 10
- Topics
- Dynamic programming, String
- Solved
- No attempts yet
Problem
A word made of lowercase English letters is given. You want to edit it so that it contains lol as a contiguous substring.
One operation is one of the following.
- Insert one lowercase English letter at any position.
- Replace one existing letter with another lowercase English letter.
- Delete one existing letter.
For each word, find the minimum number of operations needed.
Input
The first line contains the number of test cases ().
Each of the next lines contains one word. A word is made of lowercase English letters only and its length is at most .
Output
For each word, print on its own line the minimum number of operations that make lol a substring, in the order the words are given.