SPOJ AIBOHP

Googled this question. Many people have the same solution. But i am getting runtime error only.
Can anyone help??

Don’t you think you are allocating a large memory? The rte here seems to be sigsegv i.e. when we are allocating a large memory, consider a case when the length is 10^5 for both strings. Your code will reuire the memory of 10^5 * 10^5. Hence for this, u need an optimal approach for finding lcs. Please see that for finding lcs we only need the current row and the last row we filled. Isn’t it? This is the basic idea of memory optimization here. Allocate memory of 2*(no_of_col). fill the two rows i.e. x and y and for the next iteration make y as x.

Hope it helps!!

This has an excellent answer to your question:
http://codeforces.com/blog/entry/8060

It gives an easy way of maintaining the present (length l) and the previous 2 rows (length l-1 and l-2) without having to recopy arrays or keeping flags.

//