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


#1

Comment body goes here.


#2

Your code must have the space complexity of nm.
Try reducing it to 2
m.
where m is length of string B


#3

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


#4

I was getting the same error.Just initialize dp[m][n] as a vector,not as array.


#5

Just try to look at it we just require the previous row, now dp can be reduced to
dp[2][pat.length()+1].


#6

make your int 2d array vector<vector>


#7

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)