Here we can use a prefix sum algorithm
like array a[0-n] and b[0-n] let n = 5
content of a = [1,0,0,1,0] and b = [1,0,1,1,0]
after applying prefix sum we will get
a =[1,1,1,2,2] b = [1,1,2,3,3] which will take O(n)
now we will compare a[n-1] and b[n-1] so here a[n-1] is smaller so we will find the a[n-1] in b if we found it we can return te largest span