Longest Common Prefix
Module 5 · Strings
Problem
Given an array of strings, return the longest prefix shared by all of them (possibly the empty string).
Examples
Example 1
Input
["flower","flow","flight"]Output"fl"Example 2
Input
["dog","racecar","car"]Output""Constraints
1 ≤ count ≤ 200 · 0 ≤ each length ≤ 200 · lowercase letters.
Attempt it first
Small constraints — almost anything passes. So this problem is about clean decomposition, not speed. There are two natural shapes; find at least one, ideally both.