Column-first thinking
Imagine the words stacked in a table. Reading down column 0 asks "does every word start with the same letter?" before ever looking at column 1.
An autocomplete engine narrows suggestions as the user types — 'fl' matches 'flight', 'flow', 'flour'. Finding the longest shared prefix means scanning every candidate at the same character position simultaneously. At column 0 check every first letter; at column 1 every second, and so on. The moment any string disagrees — or the shortest string runs out — the prefix is complete. O(S) time where S is the sum of all characters. O(1) extra space.
Horizontal pair-by-pair comparison can over-count if the first two strings happen to share a long prefix that later strings don't. Vertical scanning guarantees every word is consulted before advancing the column pointer.
Imagine the words stacked in a table. Reading down column 0 asks "does every word start with the same letter?" before ever looking at column 1.
No prefix can be longer than the shortest input. Computing
min(len) up front gives an upper bound on the loop and
prevents out-of-bounds access.
The first character mismatch terminates the entire search. In the best case only one column is examined; in the worst case all characters of the shortest word are checked.
"".
If any word has length 0, the shortest-word length is 0 and the
outer loop never executes. The result is "".
With only one word there is nothing to compare against. The entire word is its own prefix. Return it directly.
Every column matches and the loop runs to the end of the shortest word (all words). The prefix equals the full word.