LeetCode: 14-Longest Common Prefix 解題紀錄
Last Updated on 2021-01-07 by Clay
題目
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:
Input: strs = ["flower","flow","flight"]
Output: "fl"
Input: strs = ["dog","racecar","car"]
Output: ""
題目給定一陣列,裡頭存放許多組字串,而我們要做的就是找到他們共同的前綴字串並回傳;若無共同的前綴,則回傳空字串 ""。
Read More »LeetCode: 14-Longest Common Prefix 解題紀錄