## Google Interview Question

SDE1s**Country:**United States

def matching_prefix_postfix(M, pre, post):

L = len(pre) + len(post)

for i in M:

if( L <= len(i[0]) and

pre == i[0][:2] and

post == i[0][-2:]):

return i[1]

M =[['piikukp', 40],

['pickup', 41],

['pickkkp', 42],

['pikp', 43],

['upckpi', 44]]

print("Matching number:", matching_prefix_postfix(M, 'pi', 'up'))

G =[['google', 30],

['gogle', 20]]

print("Matching number:", matching_prefix_postfix(G, 'go', 'le'))

#Output => 41, 30

```
def matching_prefix_postfix(M, pre, post):
L = len(pre) + len(post)
for i in M:
if( L <= len(i[0]) and
pre == i[0][:2] and
post == i[0][-2:]):
return i[1]
M =[['piikukp', 40],
['pickup', 41],
['pickkkp', 42],
['pikp', 43],
['upckpi', 44]]
print("Matching number:", matching_prefix_postfix(M, 'pi', 'up'))
G =[['google', 30],
['gogle', 20]]
print("Matching number:", matching_prefix_postfix(G, 'go', 'le'))
#Output : 41, 30
```

- Alex December 08, 2017