Oracle Interview Question

I was asked pattern matching question and waa asked to optimise the solution