dynamic programming merge of two strings