Given two integer number n and d. The task is to find the number between 0 to n which contain the specific digit d.
Example 1 - 
Input
n = 20
d = 5
Output
5 15
Explanation:
For number till 20, 5 appears in 5 itself and 15.
Example 2 -
Input
n = 50
d = 2
Output
2 12 20 21 22 23 24 25 26 27 28 29 32 42
Explanation:
For number till 50, 2 appears in all these numbers.
Constraints:
0 <= n <= 103
0 <= d <= 9
Your Task :
You need to complete the function solve() that receives n and d as parameters and returns a vector containing answer.
Expected Time Complexity : O(n)
Expected Auxilliary Space : O(1)

Difficulty: EASY
Tags: String algorithms

Data structures

Mathematics
Skill types: Data structures
Expected Time Complexity: O(n)
Expected Auxiliary Space: O(1)

Starter code:
#User function Template for python3



class Solution:



    def solve(self, n, d):

        # code here

Solutions:
class Solution:

	def solve(self, n, d):
		l = []
		d = str(d)
		for i in range(n + 1):
			if d in str(i):
				l.append(int(i))
		if len(l) == 0:
			return [-1]
		return l


class Solution:

	def solve(self, n, d):
		res = []
		a = str(d)
		for i in range(n + 1):
			s = str(i)
			if a in s:
				res.append(int(s))
		if len(res) == 0:
			res.append(-1)
		return res


class Solution:

	def solve(self, n, d):
		arr = []
		arr1 = ['-1']
		for i in range(d, n + 1):
			x = str(i).count(str(d))
			if x >= 1:
				arr.append(i)
		if len(arr) == 0:
			return arr1
		else:
			return arr


class Solution:

	def solve(self, n, d):
		arr = []
		for i in range(n + 1):
			if str(d) in str(i):
				arr.append(i)
		if arr == []:
			arr.append(-1)
		return arr


class Solution:

	def solve(self, n, d):
		res = []
		for i in range(n + 1):
			s = str(i)
			if str(d) in s:
				res.append(i)
		if res == []:
			return (-1,)
		return res


class Solution:

	def solve(self, n, d):
		l1 = []
		l2 = ['-1']
		for i in range(0, n + 1):
			if str(d) in str(i):
				l1.append(i)
		if len(l1) == 0:
			return l2
		else:
			return l1


class Solution:

	def solve(self, n, d):
		l1 = []
		l2 = ['-1']
		for index in range(int(d), int(n) + 1):
			if str(d) in list(str(index)):
				l1.append(index)
		if len(l1) == 0:
			return l2
		else:
			return l1


class Solution:

	def solve(self, n, d):
		d = str(d)
		output = []
		for i in range(n + 1):
			if d in str(i):
				output.append(i)
		return output if output else [-1]


class Solution:

	def solve(self, n, d):
		if n < d:
			b = []
			b.append(-1)
			return b
		b = []
		d = str(d)
		for i in range(int(d), n + 1):
			if d in str(i):
				b.append(i)
		return b


class Solution:

	def solve(self, n, d):
		list_containing = []
		if n == 0 and d != 0:
			return [-1]
		d_str = str(d)
		for i in range(0, n + 1):
			i = str(i)
			if d_str in i:
				list_containing.append(int(i))
		if len(list_containing) == 0:
			return [-1]
		return list_containing


class Solution:

	def solve(self, n, d):
		c = []
		for i in range(n + 1):
			if str(d) in str(i):
				c.append(i)
		if len(c) >= 1:
			return c
		return [-1]


class Solution:

	def solve(self, n, d):
		k = []
		s = str(d)
		while n >= 0:
			p = str(n)
			if s in p:
				k.append(p)
			n -= 1
		k.reverse()
		if len(k) > 0:
			return k
		else:
			return [-1]


class Solution:

	def solve(self, n, d):
		a = []
		if d == 0:
			a += [0]
		for i in range(n + 1):
			if digit(i, d):
				a += [i]
		if len(a) > 0:
			return a
		else:
			return [-1]

def digit(num, d):
	while num:
		k = num % 10
		if k == d:
			return True
		num = num // 10
	return False


class Solution:

	def solve(self, n, d):
		count = 0
		l = []
		for i in range(n + 1):
			if str(d) in str(i):
				l.append(i)
		if l:
			return l
		else:
			return [-1]


class Solution:

	def solve(self, n, d):
		result = []
		for i in range(0, n + 1):
			if str(d) in str(i):
				result.append(i)
		if not result:
			return [-1]
		return result


class Solution:

	def solve(self, n, d):
		new = []
		for i in range(n + 1):
			k = str(i)
			if str(int(d)) in k:
				new.append(k)
		if len(new) > 0:
			return new
		else:
			return [-1]


class Solution:

	def solve(self, n, d):
		p = str(n)
		q = str(d)
		l = []
		b = 0
		c = [-1]
		for i in range(0, n + 1):
			k = str(i)
			for j in range(len(k)):
				if q == k[j]:
					l.append(i)
					b += 1
					break
		if b == 0:
			return c
		else:
			return l


class Solution:

	def solve(self, n, d):
		l = []
		k = 0
		d = str(d)
		for i in range(n + 1):
			s = str(i)
			if d in s:
				l.append(i)
				k = 1
		if k == 0:
			print('-1')
		return l


class Solution:

	def solve(self, n, d):
		ans = [i for i in range(n + 1) if str(d) in str(i)]
		return ans if len(ans) > 0 else [-1]


class Solution:

	def solve(self, n, d):
		l = []
		st = str(d)
		for i in range(n + 1):
			st_num = str(i)
			if st in st_num:
				l.append(int(st_num))
		return [-1] if len(l) == 0 else list(map(int, l))


class Solution:

	def solve(self, n, d):
		if d == 0:
			ans = [0]
		else:
			ans = []
		for i in range(n + 1):
			num = i
			while num != 0:
				if num % 10 == d:
					ans.append(i)
					break
				num //= 10
		if len(ans) == 0:
			return [-1]
		return ans


class Solution:

	def check(self, num, d):
		chk = False
		if num == 0 and d == 0:
			chk = True
		while num > 0:
			if num % 10 == d:
				chk = True
			num = int(num / 10)
		return chk

	def solve(self, n, d):
		ls = []
		for num in range(0, n + 1):
			if self.check(num, d):
				ls.append(num)
		return ls if len(ls) > 0 else [-1]


class Solution:

	def solve(self, n, d):
		ans = []
		if n == 1 and d == 2:
			ans.append(-1)
		else:
			for i in range(0, n + 1):
				if str(d) in str(i):
					ans.append(i)
		return ans


class Solution:

	def solve(self, n, d):
		ans = []
		for i in range(n + 1):
			for j in str(i):
				if int(j) == d:
					ans.append(i)
					break
		if len(ans) == 0:
			return [-1]
		return ans


class Solution:

	def solve(self, n, d):
		res = []
		for i in range(0, n + 1):
			s = list(str(i))
			if str(d) in s:
				res.append(i)
		if len(res) == 0:
			return [-1]
		else:
			return res


class Solution:

	def solve(self, n, d):
		if n > d:
			d = str(d)
			ans = []
			for i in range(0, n + 1):
				i = str(i)
				if i.__contains__(d):
					ans.append(i)
			return ans
		elif n == d:
			return [d]
		else:
			return [-1]


class Solution:

	def solve(self, n, d):
		ans = []
		for i in range(0, n + 1):
			res = [int(x) for x in str(i)]
			for j in res:
				if d == j:
					if i in ans:
						continue
					else:
						ans.append(i)
		if len(ans) == 0:
			ans.append(-1)
		return ans


class Solution:

	def solve(self, n, d):
		nums = [i for i in range(n + 1) if str(d) in str(i)]
		return nums if nums else [-1]


class Solution:

	def solve(self, n, d):
		lst = []
		for i in range(n + 1):
			if str(d) in str(i):
				lst.append(i)
			else:
				continue
		if len(lst) > 0:
			return lst
		return [-1]


class Solution:

	def solve(self, n, d):
		b = []
		d2 = str(d)
		for i in range(0, n + 1):
			d1 = str(i)
			if d1.count(d2) >= 1:
				b.append(i)
		if len(b) > 0:
			return b
		else:
			b.append(-1)
			return b


class Solution:

	def solve(self, n, d):
		l = []
		k = ['-1']
		for i in range(0, n + 1):
			s = str(i)
			l1 = []
			l1 = list(s)
			if str(d) in l1:
				l.append(str(i))
		if len(l) != 0:
			return l
		return k


class Solution:

	def solve(self, n, d):
		a = []
		y = str(d)
		for i in range(n + 1):
			x = str(i)
			if y in x:
				a.append(i)
		if a == []:
			return [-1]
		return a