Your question is Longest Common Prefix in Strings. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
At Dropbox, file path suggestions may share a common starting segment. Given an array of strings, write a function that returns the longest common prefix shared by all strings.
If there is no common prefix, return an empty string "".
strsA correct solution should compare prefixes efficiently and handle edge cases such as a single string, empty strings, or an immediate mismatch at the first character.
def longest_common_prefix(strs):