Mastercard interview question

2 DSA questions one based on 2D string and second based on DP(Dynamic Programming)