I'd like to add an explanation:

dp[i][j] means that if I have picked i-1 characters from s1, have picked j characters from s2, whether the ith character of s1(which is s1[i-1] ) is equal to (i+j)th character of s3, which is s3[i+j-1]. If yes, dp[i][j] = true;

Similarly, dp[i][j] also means that if I have picked i characters from s1, have picked j-1 characters from s2, whether the j th character of s2(which is s2[j-1] ) is equal to (i+j)th character of s3, which is s3[i+j-1]. If yes, dp[i][j] = true;

Reference: http://blog.csdn.net/u011095253/article/details/9248073