Initialising dp [ ] [ ] to - 1.
for i in range ( n ) : NEW_LINE INDENT l = [ ] NEW_LINE for j in range ( n ) : NEW_LINE INDENT l . append ( - 1 ) NEW_LINE DEDENT dp . append ( l ) NEW_LINE DEDENT sum = 0 NEW_LINE