A Duck number is a positive number which has zeroes present in it, For example, 3210, 8050896, 70709 are all Duck numbers. A number with only leading 0s is not considered as Duck Number. For example, numbers like 035 or 0012 are not considered as Duck Numbers. A number like 01203 is considered as Duck because there is a non-leading 0 present in it.
The task is to check whether the given number N is a Duck number or not.
 
Example 1:
Input: 707069
Output: YES
Explanation: 707069 contains a non-leading 0.
 
Example 2:
Input: 02364
Output: NO
Explanation: contains only leading 0.
 
Your Task:
Your task is to complete the function check_duck() which takes a single argument(string N) and returns true if N is a Duck number else false. You need not take input or print anything. The driver code will itself print "YES" if the returned value is true and "NO" if the returned value is false.
Expected Time Complexity: O(|N|).
Expected Auxiliary Space: O(1).
 
Constraints :
1 ≤ Length of N ≤ 10^{4}

Source: geeksforgeeks | Difficulty: EASY
Tags: String algorithms

Data structures

Starter code: #User function Template for python3



class Solution:



    def check_duck(self, N):

        # code here

Solutions:
class Solution:

	def check_duck(self, N):
		n = str(N)
		if n[0] == '0':
			return False
		elif '0' in n:
			return True
		else:
			return False


class Solution:

	def check_duck(self, N):
		if int(N) >= 10:
			for i in range(len(N)):
				if int(N[i]) > 0:
					if '0' in N[i + 1:]:
						return 1
			return 0
		else:
			return 0


class Solution:

	def check_duck(self, N):
		if N == '0':
			return 0
		if N[0] == '0':
			return 0
		else:
			for i in N:
				if i == '0':
					return 1
			else:
				return 0


class Solution:

	def check_duck(self, N):
		if N == '0':
			return 0
		if N[0] == '0':
			return 0
		elif '0' in N:
			return 1
		else:
			return 0


class Solution:

	def check_duck(self, N):
		if N[0] == '0':
			return False
		for i in range(1, len(N)):
			if N[i] == '0':
				return True
		else:
			return False


class Solution:

	def check_duck(self, N):
		s = str(N)
		while s and s[0] == '0':
			s = s[1:]
		if '0' in s:
			return True
		return False


class Solution:

	def check_duck(self, N):
		a = str(N)
		b = int(a)
		c = str(b)
		if c == '0':
			return False
		if '0' in c:
			return True
		else:
			return False


class Solution:

	def check_duck(self, N):
		st = str(N)
		if '0' in st and st[0] != '0':
			return 1
		return 0


class Solution:

	def check_duck(self, N):
		st = str(int(N))
		if st != '0' and '0' in str(int(N)):
			return True
		return False


class Solution:

	def check_duck(self, N):
		c = 0
		if len(N) == 1 and [0] == '0':
			return False
		for i in range(len(N)):
			if N[0] == '0':
				return False
				break
			elif N[i] == '0':
				c = c + 1
		if c != 0:
			return True
		return False


class Solution:

	def check_duck(self, N):
		p = str(N)
		s = 0
		for i in p:
			if i == '0':
				s += 1
		if p[0] != '0' and s > 0:
			return True
		return False


class Solution:

	def check_duck(self, N):
		b = int(N)
		if len(str(N)) < 2:
			return False
		elif str(N)[0] == '0' and '0' not in str(b):
			return False
		elif str(N)[0] != '0' and '0' in str(b):
			return True
		elif str(N)[0] == '0' and '0' in str(b):
			return True


class Solution:

	def check_duck(self, N):
		if len(str(int(N))) >= 2:
			N = str(int(N))
		else:
			return False
		if '0' in N:
			return True
		return False


class Solution:

	def check_duck(self, N):
		a = str(N)
		if '0' in a:
			if a[0] == '0':
				return False
			else:
				return True


class Solution:

	def check_duck(self, N):
		if N[0] == '0':
			return False
		elif '0' in N and len(N) != 1:
			return True
		else:
			return False


class Solution:

	def check_duck(self, N):
		if N[0] == '0':
			return 0
		elif N.count('0') >= 1:
			return 1


class Solution:

	def check_duck(self, N):
		if N[0] == '0':
			return False
		elif len(set(N)) == 1:
			return False
		elif '0' in N:
			return True


class Solution:

	def check_duck(self, N):
		n = len(N)
		i = 0
		while i < n and N[i] == '0':
			i = i + 1
		while i < n:
			if N[i] == '0':
				return True
			i = i + 1
		return False


class Solution:

	def check_duck(self, N):
		while '0' == N[0] and int(N) != 0:
			N = N[1:]
		if '0' in N and int(N) != 0:
			return True
		return False


class Solution:

	def check_duck(self, N):
		number_string = str(N)
		check = number_string[0]
		if number_string.count('0') >= 1:
			if check != '0':
				return True
			else:
				return False


class Solution:

	def check_duck(self, N):
		N = str(N)
		if N == '0':
			return 0
		s = str(int(N))
		if '0' in s:
			return 1
		else:
			return 0


class Solution:

	def check_duck(self, N):
		while N and N[0] == '0':
			N = N[1:]
		return '0' in N if N else False


class Solution:

	def check_duck(self, N):
		N = int(N)
		while N != 0:
			if N % 10 == 0:
				return True
			N = N // 10
		else:
			return False


class Solution:

	def check_duck(self, s):
		if s[0] == '0':
			return False
		for i in range(1, len(s)):
			if s[i] == '0':
				return True
		return False


class Solution:

	def check_duck(self, N):
		c = str(N).count('0')
		s = str(N)
		if s[0] == '0' and c == 1:
			return 0
		elif c == 0:
			return 0
		elif s[1] == '0' and s[0] == '0':
			return 0
		return 1


class Solution:

	def check_duck(self, N):
		N = str(int(N))
		if N == '0':
			return False
		else:
			return N.__contains__('0')


class Solution:

	def check_duck(self, N):
		for i in range(len(N)):
			if N[0] == '0':
				return False
			elif N[i] == '0':
				return True


class Solution:

	def check_duck(self, N):
		c1 = c2 = 0
		if N[0] == '0':
			c1 += 1
		for i in range(1, len(N)):
			if N[i] == '0':
				c2 += 1
		if c1 == 1:
			return 0
		elif c2 == 0:
			return 0
		else:
			return 1


class Solution:

	def check_duck(self, N):
		a = len(N)
		for i in range(a):
			if N[0] == '0':
				return 0
			elif N[i] == '0':
				return 1


class Solution:

	def check_duck(self, N):
		a = str(N)
		if len(a) > 1:
			for i in range(len(a)):
				if a[i] == '0':
					continue
				elif a[i] != '0':
					break
			if '0' in a[i + 1:]:
				return 1
			else:
				return 0
		elif N == 0:
			return 0


class Solution:

	def check_duck(self, N: str) -> bool:
		i = 0
		while i < len(N) and N[i] == '0':
			i += 1
		for x in N[i:]:
			if x == '0':
				return True
		return False


class Solution:

	def check_duck(self, N):
		return '0' in str(int(N)) and N != '0'


class Solution:

	def check_duck(self, N):
		s = str(N)
		l = 0
		k = 0
		for i in range(len(s)):
			if s[i] != '0':
				k = i
				break
		if '0' in s[k:]:
			l = 1
		if N == '0':
			l = 0
		if l == 1:
			return True
		else:
			return False


class Solution:

	def check_duck(self, N):
		rem = -1
		x = str(N)
		y = ''
		for i in range(len(x)):
			if x[i] != '0':
				y = x[i:]
				break
			else:
				pass
		if '0' in y:
			return 1
		else:
			return 0


class Solution:

	def check_duck(self, N):
		if N[0] == '0':
			return False
		elif '0' in N:
			return True
		elif '0' not in N:
			return False
		return True


class Solution:

	def check_duck(self, N):
		s = str(N)
		for i in range(len(s)):
			if s[0] == '0':
				return False
		for i in s:
			if i == '0':
				return True


class Solution:

	def check_duck(self, N):
		N = int(N)
		m = 1
		while N != 0:
			k = N % 10
			m = m * k
			N = N // 10
		if m == 0:
			return True
		return False


class Solution:

	def check_duck(self, N):
		n = int(N)
		n = str(n)
		if len(n) == 1:
			if n[0] == '0':
				return False
			else:
				return True
		for i in n:
			if i == '0':
				return True
		return False


class Solution:

	def check_duck(self, N):
		num = str(N)
		i = 0
		if N == '0':
			return 0
		while i < len(num) and num[i] == '0':
			i += 1
		while i < len(num):
			if num[i] == '0':
				return 1
			i += 1
		return 0


class Solution:

	def check_duck(self, N):
		if int(N) == 0:
			return False
		return True if str(int(N)).count('0') > 0 else False


class Solution:

	def check_duck(self, N):
		num = int(N)
		if num == 0:
			return False
		if '0' in str(num):
			return True
		else:
			return False


class Solution:

	def check_duck(self, N):
		if '0' in N[1:]:
			if N[0] != '0':
				return True
		return False


class Solution:

	def check_duck(self, N):
		e = str(N)
		if '0' in e and e[0] != '0':
			return 1
		else:
			return 0


class Solution:

	def check_duck(self, N):
		s = str(N)
		if not s.startswith('0') and '0' in s:
			return True
		else:
			r = [x for x in range(len(s)) if s[x] == '0']
			if len(r) == 1:
				return False
			for x in range(len(r) - 1):
				if r[x + 1] - r[x] > 1:
					return True
		return False


class Solution:

	def check_duck(self, N):
		if int(N) == 0:
			return 0
		else:
			for i in range(1, len(N)):
				if int(N[i]) == 0:
					if N[i - 1] > N[i]:
						return 1
				else:
					continue
			else:
				return 0
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = input()
		solObj = Solution()
		if solObj.check_duck(N):
			print('YES')
		else:
			print('NO')


class Solution:

	def check_duck(self, N):
		return str(N)[0] != '0' and '0' in str(N)
s = Solution()
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = input()
		solObj = Solution()
		if solObj.check_duck(N) == True:
			print('YES')
		else:
			print('NO')


class Solution:

	def check_duck(self, N):
		num = str(N)
		flag = False
		count = 0
		for ele in num:
			if ele == '0':
				count += 1
		for ele in num:
			if ele == '0':
				flag = True
			else:
				if flag or count == 0:
					return False
				return True
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = input()
		solObj = Solution()
		if solObj.check_duck(N):
			print('YES')
		else:
			print('NO')


class Solution:

	def check_duck(self, N):
		flag = False
		for i in N:
			if ord(i) >= ord('1') and ord(i) <= ord('9'):
				flag = True
			elif flag:
				return True
		return False
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = input()
		solObj = Solution()
		if solObj.check_duck(N):
			print('YES')
		else:
			print('NO')


class Solution:

	def check_duck(self, N):
		k = str(N)
		if len(set(k)) == 1 and '0' in k:
			return 0
		if k[0] == '0':
			r = len(k) - k[::-1].index('0')
			if '0' in k[r:]:
				return 1
			else:
				return 0
		elif '0' in k:
			return 1
		else:
			return 0
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = input()
		solObj = Solution()
		if solObj.check_duck(N):
			print('YES')
		else:
			print('NO')


class Solution:

	def check_duck(self, N):
		start = False
		for x in str(N):
			if x == '0' and start:
				return 'YES'
			elif x != '0':
				start = True
		return False
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = input()
		solObj = Solution()
		if solObj.check_duck(N):
			print('YES')
		else:
			print('NO')


class Solution:

	def check_duck(self, N):
		lst = list(N)
		for itr in range(len(lst) - 1):
			if lst[itr] != '0' and lst[itr + 1] == '0':
				return True
		return False
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = input()
		solObj = Solution()
		if solObj.check_duck(N):
			print('YES')
		else:
			print('NO')


class Solution:

	def check_duck(self, N):
		flag = False
		for i in range(1, len(N)):
			if N[i] == '0' and N[0] != '0':
				flag = True
		return flag
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = input()
		solObj = Solution()
		if solObj.check_duck(N):
			print('YES')
		else:
			print('NO')


class Solution:

	def check_duck(self, N):
		N = N.lstrip('0')
		if N.count('0') > 0:
			return True
		return False
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = input()
		solObj = Solution()
		if solObj.check_duck(N):
			print('YES')
		else:
			print('NO')