Confluent interview question

Similar to wildcard pattern matching using Dynamic Programming.