Problem · String

Programmer Strings

MediumMicrosoftOA
See Microsoft hiring insights

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 Description

Complete the function programmerStrings in the editor below.

Examples
01 · 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.

More Microsoft problems
drafts saved locally
public int programmerStrings(String s) {
  // write your code here
}
s"programmerxxxprozmerqgram"
expected3
sign in to submit