Common Prefix
Start Timer
0:00:00
Given a list of strings, write a function that returns their longest common prefix. For example, if you were given the strings “flowers
”, “flow
”, and “flight
”, your function should return the string “fl
”.
If the list of strings has no common prefix, return an empty string.
Example 1:
Input:
strings = ["flowers", "flow", "flight"]
Output:
"fl"
Example 2:
Input:
strings = ["showboat", "showcase", "shower"]
Output:
"show"
Recommended questions for you
Personalized based on your user activity, skill level, and preferences.
.
.
.
.
.
.
.
.
.
Comments