leetcode: Longest Common Prefix

Problem Description:

Write a function to find the longest common prefix string among an array of strings.

Solution and Precautions:

First sort the array of strings, and just compare each character of the first string and the last string from the start to the end of the shorter string, stop when reaching the end of string or reach a not matched character.

Written on April 21, 2013