2
def findLatestStep(self, arr: List[int], m: int) -> int:6
return m # just in case8
# make in "inverted" array with artificial ends higher then everything between10
sor = [0 for _ in range(n + 2)]13
sor[0] = sor[n + 1] = n + 115
# scan and see, if ones in the middle of space of length m appear16
# before ones on its ends,17
# and find the latest of such spaces to disappear, if exists19
for i in range(1, n - m + 2):21
sor[i - 1] > sor[j] and sor[i + m] > sor[j] for j in range(i, i + m)23
if min(sor[i - 1] - 1, sor[i + m] - 1) > ans:24
ans = min(sor[i - 1] - 1, sor[i + m] - 1)