A library wants to know how the titles in a series begin. Given a list of strings titles, return the longest string that is a prefix of every title. If the list is empty or the titles share no first character, return "".
Examples
Input: titles = ["interstellar", "internet", "interval"]
Output: "inter"
Input: titles = ["apple", "banana"]
Output: ""
Constraints
0 <= len(titles) <= 5000, each title up to 200 characters- Target: O(total number of characters) time.
Goals
- Compare strings column by column
- Stop at the first column where any string differs or ends
- Return an empty string for an empty list