While describing the recursive relation in the lecture, sir has explained and thus used the condition:
if( S1 [i] == S2 [j] )
then return 1+ f( S1, S2, i+1, j+1)
else{
…
but in his code he has used
if( S1 [i] == S2 [i] )
then return 1+ f( S1, S2, i+1, j+1)
else{
Notice the difference in the if statements.
And for this simple test case this pece of code seems to work, but is it correct and will it work for all the test cases?