Company: Cashfree

Difficulty: medium

Problem Statement

8. Programmer String Call a substring a programmer string if its letters can be shuffled into the word 'programmer'. Under this rule, 'programmerpro', 'grammerpro', and 'prozmeragram' would all qualify as programmer strings. Given a string that is known to contain exactly two non-overlapping programmer strings, count how many character positions sit strictly between the leftmost one and the rightmost one. Function Description Complete the function programmerStrings in the editor below. programmerStrings has the following parameter(s): string s : a string containing 2 programmer strings Returns: int : the count of positions lying strictly between the two programmer strings found in s Constraints String s consists of lowercase English alphabetic letters only, ascii[a-z] 1 ≤ the length of s ≤ 10 5 There will always be two non-overlapping programmer strings Example s = 'programmerxxxprozmeragram' 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 p r o g r a m m e r x x x p r

More Cashfree OA questionsInterview experiences