Link: https://leetcode.com/problems/longest-common-prefix/
Solution:
Topics: vertical scan
Intuition
Cute little problem with a couple interesting edge cases. Simple vertical scan will do.
- If the length of
strs
is 1, returnstrs[0]
. - It could be the case that
strs
are all duplicates so don’t rely on the exit condition to return the result.
Implementation
Review 1
Too easy.