from typing import List
def longest_chain(submatrix: List[int]) -> int:
\"\"\"
Given a list of integers, return the length of the longest chain of1's
that start from the beginning.
You MUST use a while loop for this! We will check.
>>> longest_chain([1, 1, 0])
2
>>> longest_chain([0, 1, 1])
0
>>> longest_chain([1, 0, 1])
1
\"\"\"
i = 0
a = []
while i < len(submatrix) and submatrix[i] != 0:
a.append(submatrix[i])
i += 1
return sum(a)
def largest_rectangle_at_position(matrix: List[List[int]], x: int,y: int
) -> int:
\"\"\"
Returns the area of the largest rectangle whose top left corner isat
position , in .
You MUST make use of here as you loop through each row
of the matrix. Do not modify the input matrix.
>>> case1 = [[1, 0, 1, 0, 0],
... [1, 0, 1, 1, 1],
... [1, 1, 1, 1, 1],
... [1, 0, 0, 1, 0]]
>>> largest_rectangle_at_position(case1, 0, 0)
4
>>> largest_rectangle_at_position(case1, 2, 0)
5
>>> largest_rectangle_at_position(case1, 1, 2)
6
\"\"\"
pass
replace the word pass with a function body byimplementing the 1st function. make sure nested loops can be a maxof 3. try to keep it as short as possible and fulfill the docstringrequirements