Given a set of inputs consisting of only 0’s and 1’s find the farthest 0 from a 1.
Example1 : 1 0 0 0
Answer1 : 3 ( 4 - 1) The indices
Example2 : 1 0 0 1
Answer2 : 2
My Approach:
li = list(map(int,input().split()))
left = 0
right = len(li)
while(li[left]==1 and li[right-1]==1):
right -= 1
lefttoright = right-left-1
left = 0
right = len(li)
while(li[right-1]==1 and li[left]==1):
left += 1
righttoleft = right-left-1
print(max(lefttoright,righttoleft))