compare prefix of every string, if not same or reach string end, then break