check Wildcard Matching in dynamic programming