Help with python syntax

In the question a piece of code is
def maxArea(self, height: List[int]) → int:
Please explain this line of code

These are for type specification. As you know Python is dynamically typed; which is we don’t say int a = 5; or float a = 5.5; just a = 5 or a = 5.5

This can be confusing when passing things to functions. Can lead to unexpected behaviour. So ‘typing’ module allows typing hints.

So in your function maxArea takes in one argument, a list of integers and returns an integer.

Suppose you wanted to take in a int and a List of strings and return nothing you would write

def fn(x: int, y: List[str]) -> None:

2 Likes

thanks buddy

1 Like