question 109 String Algorithms · medium
The shared start of several codes
A warehouse groups bin labels by their shared start: A12-07, A12-09 and A12-11 all start with A12-. Return the longest text that every label starts with. The comparison is exact (case matters).
Function
common_prefix(labels)Returnsthe longest shared start of every text in the list;
"" if there is none or the list is emptyExamples
callcommon_prefix(['A12-07', 'A12-09', 'A12-11'])returns'A12-'
callcommon_prefix(['HOM-22847', 'HOM-22850', 'HOM-31000'])returns'HOM-'
callcommon_prefix(['B1', 'C1'])returns''