log in
About and Contact
© 2020 DOUBTCOOL
Python Code:-
for t in range(int(input())):
n=input()
n1=n.count('1')
n0=n.count('0')
if(n1==1 or n0==1):
print("Yes")
else:
print("No")
Python code
# author : SJ
zero=0
one =0
for t in range(int(input())):
s = (input())
for i in s:
if i=='0':
zero+=1
else:
one+=1
if one>zero and one-zero==1:
print("Yes")
elif zero>one and zero-one==1:
print("Yes")
else:
print("No")