Sobes.tech
Intern — Middle

Finding the longest common prefix among strings

livecode

Task condition

Given an array of strings. Implement a function that returns the longest common prefix among all elements of the array.

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

Example 2: Input: ["dog", "cat"] Output: ""