def f(s) arr=[] old="" p1=0 s.chars{|e| if old==e if e=="o" p1+=1 else p1-=1 end else arr<n if i>0 ans=[ans,n+s[i-1]].max end if i0 t2+=s[i-1] end if i