← 返回 sofi 的题目列表Find the distance from mid index to closest index
类型:online_judge
Given an array, you need to find the index i such that 1s to the left of i are 0, and the distance to the nearest 1 on the right side is minimized. Implement the function def find_mid_index_distance(arr: List[int]) -> int: to achieve this. Assume the input is always valid and there is at least one 1.
Example:
Input: [1,0,0,0,1,0,1]
Output: 2
You need to return the index.
Example
Input
[1,0,0,0,1,0,1]