O(n) Contiguous Subarray in Python You are given an array arr of N integers. For each index i, you are…