== cost of string concatenation == 
 I think it's not justified to say that string concat is O(n+m), 
 one has to distinguish 
 * the search for the end token (in O(n), but only READ), and 
 * the creation of the new string (requiring 
 :* memory allocation (which might be more expensive than all the rest, depending on implementation (default MEM_CLEAR or so)) 
 :* COPYING of the first and then the second string (READ + WRITE in another memory segment, O(n+m) operations) 
 On the other hand, if one uses reference counting and allows for segmented string storage, then the concatenation takes virtually no time. 

 Concerning "memoization", why the heck did this guy not call it memorization ??? (Or memo'ization ?) 

 And finally, I would be astonished if there was no better ("local") method for optimizing this matrix problem, rather than checking all possible combinations... I'll think about this...