Find the longest common prefix string amongst an array of strings.
Write a program that takes an array of lowercase strings and returns the longest common prefix (LCP) that is shared amongst all strings. If there is no common prefix, return an empty string. The words are separated by a space character.
# | Size | % | Users |
---|---|---|---|
#1 | 32 c. | Top 4% | |
#2 | 35 c. | Top 8% | c |
#3 | 36 c. | Top 16% | |
#4 | 37 c. | Top 28% | |
#5 | 38 c. | Top 32% | |
#6 | 39 c. | Top 36% | |
#7 | 67 c. | Top 40% | |
#8 | 71 c. | Top 44% | |
#9 | 75 c. | Top 48% | |
#10 | 77 c. | Top 52% | |
#11 | 79 c. | Top 64% | |
#12 | 81 c. | Top 72% | |
#13 | 84 c. | Top 80% | |
#14 | 87 c. | Top 84% | |
#15 | 99 c. | Top 88% | |
#16 | 150 c. | Top 92% | |
#17 | 398 c. | Top 96% | |
#18 | 433 c. | Top 100% |