Initialize the array with - 1
for ( int [ ] row : dp ) { Arrays . fill ( row , - 1 ) ; } System . out . println ( " MINIMUM ▁ NUMBER ▁ OF ▁ DELETIONS : ▁ " + ( s1 . length ( ) - transformation ( s1 , s2 , 0 , 0 ) ) ) ; System . out . println ( " MINIMUM ▁ NUMBER ▁ OF ▁ INSERTIONS : ▁ " + ( s2 . length ( ) - transformation ( s1 , s2 , 0 , 0 ) ) ) ; System . out . println ( " LCS ▁ LENGTH : ▁ " + transformation ( s1 , s2 , 0 , 0 ) ) ; } }