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.
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
- Rank Open BusinessesPHONE SCREEN · Seen May 2026
- Retain Top K ValuesPHONE SCREEN · Seen May 2026
- In-Memory SQL with CSV InitializationONSITE INTERVIEW · Seen May 2026
- Order Records by Matching Start and EndONSITE INTERVIEW · Seen May 2026
- Recover Corrupted Master PageONSITE INTERVIEW · Seen Feb 2026
- Distinct Number Line MovesOA · Seen Oct 2025
- Minimum Round Trip LengthsOA · Seen Aug 2025
- Get Minimum TimeSeen Jun 2025
public int programmerStrings(String s) {
// write your code here
}s"programmerxxxprozmerqgram"
expected3
sign in to submit