Comment body goes here.

# My code is showing correct answer but in efficiency is showing segmentation fault. Please help!

Your code must have the space complexity of n*m.
Try reducing it to 2*m.

where m is length of string B

I was getting the same error. Then I changed my integer dp[n][m] array to boolean, it got accepted.

Just try to look at it we just require the previous row, now dp can be reduced to

dp[2][pat.length()+1].

memory and time restrictions are tight.

use a dp of 2*(a.size()) length. because you only need the elements of the previous column so no need to have another vector the size of string b

time should be o(m*n)