Problem · String
Programmer Strings
Learn this problemProblem statement
A programmer string contains letters that can be rearranged to form the word programmer and is a substring of a longer string.
Note that the strings programmer, grammproer, and prozmerqgram are all classified as programmer strings by this definition.
Given a string, determine the number of indices that lie between the rightmost and leftmost programmer strings that it contains.
Function
programmerStrings(s: String) → intComplete the function programmerStrings in the editor below.
Examples
Example 1
s = "programmerxxxprozmerqgram"return = 3
In this example, indices 0 - 9 form one programmer string and indices 13 - 24 contain another.
There are 3 indices between the programmer strings, so the function will return 3.