Initialize the array with - 1
for ( int m = 0 ; m < 2000 ; m ++ ) { for ( int n = 0 ; n < 2000 ; n ++ ) { dp [ m , n ] = - 1 ; } } Console . WriteLine ( " MINIMUM ▁ NUMBER ▁ OF ▁ DELETIONS : ▁ " + ( s1 . Length - transformation ( s1 , s2 , 0 , 0 ) ) ) ; Console . WriteLine ( " MINIMUM ▁ NUMBER ▁ OF ▁ INSERTIONS : ▁ " + ( s2 . Length - transformation ( s1 , s2 , 0 , 0 ) ) ) ; Console . WriteLine ( " LCS ▁ LENGTH : ▁ " + transformation ( s1 , s2 , 0 , 0 ) ) ; } }