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 3% | |
#2 | 34 c. | Top 7% | |
#3 | 35 c. | Top 10% | c |
#4 | 36 c. | Top 17% | |
#5 | 37 c. | Top 27% | |
#6 | 38 c. | Top 30% | |
#7 | 39 c. | Top 33% | |
#8 | 65 c. | Top 37% | |
#9 | 67 c. | Top 40% | |
#10 | 71 c. | Top 43% | |
#11 | 75 c. | Top 47% | |
#12 | 76 c. | Top 50% | |
#13 | 77 c. | Top 53% | |
#14 | 78 c. | Top 57% | |
#15 | 79 c. | Top 67% | |
#16 | 81 c. | Top 73% | |
#17 | 84 c. | Top 80% | |
#18 | 87 c. | Top 83% | |
#19 | 99 c. | Top 87% | |
#20 | 150 c. | Top 90% | |
#21 | 344 c. | Top 93% | c |
#22 | 398 c. | Top 97% | |
#23 | 433 c. | Top 100% |