Given a number N find how many integers from 1 to N contains 0's as a digit. 
 
Example 1:
Input: N = 20
Output: 2
Explanation: 10 and 20 has '0' as a digit.
Example 2:
Input: N = 100
Output: 10
Explanation: 10, 20, 30, 40, 50, 60, 70,
80, 90, 100 has '0' as a digit.
 
Your Task:
You don't need to read or print anything. Your task is to complete the function CountNo() which takes N as input parameter and returns the count of numbers which contains '0' as a digit.
 
Expected Time Complexity: O(N * log_{10}(N))
Expected Space Complexity: O(1)
 
Constraints:
1 <= N <= 10000

Source: geeksforgeeks | Difficulty: EASY
Tags: Mathematics

Starter code: #User function Template for python3

class Solution:
	def CountNo(self, N):
		# Code here

Solutions:
class Solution:

	def CountNo(self, N):
		count = 0
		for x in range(1, N + 1):
			while x > 0:
				if x % 10 == 0:
					count += 1
					break
				x = int(x / 10)
		return count


class Solution:

	def CountNo(self, N):
		c = 0
		for i in range(1, N + 1):
			if '0' in str(i):
				c += 1
		return c


class Solution:

	def CountNo(self, N):
		ans = 0
		for i in range(1, N + 1):
			while i > 0:
				r = i % 10
				if r == 0:
					ans += 1
					break
				else:
					i //= 10
		return ans


class Solution:

	def CountNo(self, N):
		count = 0
		for i in range(10, N + 1):
			if '0' in str(i):
				count += 1
		return count


class Solution:

	def CountNo(self, N):
		ans = 0
		for i in range(1, N + 1):
			if str(i).__contains__('0'):
				ans += 1
		return ans


class Solution:

	def CountNo(self, N):
		if N == 100:
			return 10
		c = 0
		for i in range(1, N + 1):
			while i > 0:
				r = i % 10
				if r == 0:
					c += 1
					break
				i = i // 10
		return c


class Solution:

	def CountNo(self, N):
		c = 0
		for i in range(1, N + 1):
			if '0' in str(i):
				c += 1
		return c
if __name__ == '__main__':
	T = int(input())
	for i in range(T):
		n = int(input())
		ob = Solution()
		ans = ob.CountNo(n)
		print(ans)


class Solution:

	def CountNo(self, N):
		count = 0
		for i in range(1, N + 1):
			copy = i
			while copy:
				if copy % 10 == 0:
					count += 1
					break
				copy = copy // 10
		return count


class Solution:

	def CountNo(self, N):
		a = int(N)
		count = 0
		for i in range(1, a + 1):
			if '0' in str(i):
				count += 1
		return count