Question Asked by Vmware

Hi Friends,

Could you help me to solve this problem I have tried no luck.

we consider a string to be programmer string if some subset of its letters can be rearranged to form the word programmer.
for example , the strings “programmer”,“grammproer” and “xprozmerqgram” are all programmer strings. given a long string
,determine the indices within the string that are between two programmer strings as an example

s ="programmerxxxprozmerqgram"

the order of the letters does not matter . each of x character is between two programmer, so 3 indices meets test

s is [a-z]
1<s<10^5


example :
progxrammerrxproxgrammer
i =11 and i = 12 

p r o g x r a m m e  r  r  x  p  r  o  x  g  r  a  m  m  e  r
0 1 2 3 4 5 6 7 8 9 10 11 12 13  14 15 16 17 18 19 20 21 22 23


there are two indices i = 11 and i = 12 that satisfy the property that substring s[0,i-1],s[i+1,n-1] are both programmer string

Use an additional array to store the indices that wheather a word can be formed using the letters till i , once u get that , keep incrementing i till you got another programmer and between that indices put the value of array to zero .
Then you can easily evaluate the answer by just subtracting the 2 indices in the array .
If you still have confusion , then you can ask me for code .

Thanks Abhishek,
Could you please pseudo code ?

Thanks
Naresh

how can we analyze the another substring from where it start ?

Regular expression is widely used for pattern matching . Python has a built-in package called re , which can be used to work with Regular Expressions . The re module contains a function called search() , it can be used to check if a string contains the specified search pattern .

re.search(pattern, string, flags[optional])