leetcode.jp 博客
本网站所有文字及图片内容均来自网络,每周定时更新,仅供个人学习与研究,请勿用于商业用途。谢谢合作。

14. Longest Common Prefix

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

If there is no common prefix, return an empty string "".

Example 1:

Input: ["flower","flow","flight"]
Output: "fl"

Example 2:

Input: ["dog","racecar","car"]
Output: ""
Explanation: There is no common prefix among the input strings.

Note:

All given inputs are in lowercase letters a-z.

Difficulty:

Easy

Lock:

Normal

Company:

Adobe Alibaba Amazon Apple Bloomberg Cisco Citrix Facebook Google IBM IXL Microsoft Oracle Pinterest Quora Snapchat Splunk Twilio Twitter Visa Yahoo Yelp

Solution(Chinese):

LEETCODE 14. Longest Common Prefix 解题思路分析