0

Please explain the syntax in the arguments of the longestCommonPrefix function. This function takes a list of strings as inputs.

class Solution:
    def longestCommonPrefix(self, strs: List[str]) -> str:


Alex Ferguson
  • 107
  • 2
  • 10
  • Does this answer your question? [What does -> mean in Python function definitions?](https://stackoverflow.com/questions/14379753/what-does-mean-in-python-function-definitions) – 0x5453 Mar 05 '20 at 16:06

1 Answers1

2

The arguments and the -> describe the type of the function.

def longestCommonPrefix(self, strs: List[str]) -> str:
    pass

So it takes one argument, strs which is a list of strings (List[str]).
Then it returns a string (str).

blueteeth
  • 3,330
  • 1
  • 13
  • 23
  • 1
    To add to this answer, the `self` argument means this function is a non-static member function of some class – LLSv2.0 Mar 05 '20 at 16:07