0

I have a list of strings in python. I want to write a python code to find the longest common prefix string among an array of strings. The common leading characters in all elements of the string is returned to output.

Here is a toy example. If the input is as follows:

strings = ["redlight", "realworld", "reason"]

The output would be:

["re"]

If the input is as follows:

strings = ["apple", "orange", "reason"]

The output would be:

[""]
Matt
  • 85
  • 6

0 Answers0