17: Longest common prefix

Given an array of strings, find the longest common prefix string among the array items

 

Example 1

Input: [code, coffee]

Output: co

Example 2

Input: [code, rest]

Output: ""

Note: return an empty string if there is no common prefix

Difficulty:Easy
Topic:String
Problem #:17