Write a function to find the longest common prefix string among an array of strings. If there is no common prefix, return an empty string "".
strs = ["flower","flow","flight"]"fl"strs = ["dog","racecar","car"]""prefix = strs[0] (candidate starts as the first string)i = 1 to n−1: check strs[i].startsWith(prefix)strs[i] does not start with prefix: trim one char from the rightprefix becomes empty → return "" immediatelyprefixHorizontal scanning treats strs[0] as the candidate prefix. The prefix can only shrink — it is trimmed from the right until it matches each subsequent string. Once trimmed to match all strings, it is the longest possible common prefix. S = total characters across all strings.