Home | Projects | Notes > Problem Solving > LC - E - 14. Longest Common Prefix

LC - E - 14. Longest Common Prefix

 

Solutions in C++

Solution 1

This solution takes the first string in the vector strs as a reference, and compares character by character throughout all the strings in strs.

Complexity Analysis:

Solution:

line 6: Termination condition can also be written as strs[0].length().