Uber Interview Question

A question similar to deletion distance algorithms problem