Initialize the array with - 1
memset ( dp , -1 , sizeof dp ) ; cout << " MINIMUM ▁ NUMBER ▁ OF ▁ DELETIONS : ▁ " << ( s1 . size ( ) ) - transformation ( s1 , s2 , 0 , 0 ) << endl ; cout << " MINIMUM ▁ NUMBER ▁ OF ▁ INSERTIONS : ▁ " << ( s2 . size ( ) ) - transformation ( s1 , s2 , 0 , 0 ) << endl ; cout << ( " LCS ▁ LENGTH : ▁ " ) << transformation ( s1 , s2 , 0 , 0 ) ; }