Given a string S and set of strings U. Find the length of longest prefix of S that can be formed using strings in U.

For example you have following -

```
S= “absolute”
U={“abs”,”xyz”,”ol”,”te”}
```

Answer: 5 i.e "absol"

Now the task is to have the algorithm/program for the above problem, please help me with this?