Given a number N. Your task is to check whether it is fascinating or not.
Fascinating Number: When a number(should contain 3 digits or more) is multiplied by 2 and 3, and when both these products are concatenated with the original number, then it results in all digits from 1 to 9 present exactly once.
Example 1:
Input: 
N = 192
Output: Fascinating
Explanation: After multiplication with 2
and 3, and concatenating with original
number, number will become 192384576 
which contains all digits from 1 to 9.
Example 2:
Input: 
N = 853
Output: Not Fascinating
Explanation: It's not a fascinating
number.
Your Task:  
You don't need to read input or print anything. Your task is to complete the function fascinating() which takes the integer n parameters and returns boolean(True or False) denoting the answer.
Expected Time Complexity: O(1)
Expected Auxiliary Space: O(1)
Constraints:
100 <= N <= 2*10^{9}

Source: geeksforgeeks | Difficulty: EASY
Tags: Data structures

Starter code: #User function Template for python3

class Solution:



	def fascinating(self,n):

	    # code here

Solutions:
class Solution:

	def fascinating(self, n):
		f = n * 2
		s = n * 3
		S = list(str(n) + str(f) + str(s))
		S.sort()
		if S == ['1', '2', '3', '4', '5', '6', '7', '8', '9']:
			return True
		else:
			return False


class Solution:

	def fascinating(self, n):
		num = '123456789'
		a = str(n) + str(n * 2) + str(n * 3)
		count = 0
		for i in num:
			if i in a:
				count += 1
		if count == 9 and len(a) == 9:
			return True
		else:
			return False


class Solution:

	def fascinating(self, n):
		a = ['1', '2', '3', '4', '5', '6', '7', '8', '9']
		b = sorted(str(n) + str(n * 2) + str(n * 3))
		if a == b:
			return True


class Solution:

	def fascinating(self, n):
		return list('123456789') == sorted(str(n) + str(n * 2) + str(n * 3))


class Solution:

	def fascinating(self, n):
		ml = ['1', '2', '3', '4', '5', '6', '7', '8', '9']
		l = '' + str(n) + str(n * 2) + str(n * 3)
		i = list(l)
		return sorted(i) == ml


class Solution:

	def fascinating(self, n):
		record = ['1', '2', '3', '4', '5', '6', '7', '8', '9']
		final = ''
		final += str(n)
		final += str(n * 2)
		final += str(n * 3)
		final = sorted(final)
		return final == record


class Solution:

	def fascinating(self, n):
		if n >= 100:
			record = ['1', '2', '3', '4', '5', '6', '7', '8', '9']
			n1 = str(n)
			n2 = str(n * 2)
			n3 = str(n * 3)
			total_n = n1 + n2 + n3
			total_n = sorted(total_n)
		return total_n == record


class Solution:

	def fascinating(self, n):
		record = [str(i) for i in range(1, 10)]
		ans = sorted(str(n) + str(n * 2) + str(n * 3))
		return ans == record


class Solution:

	def fascinating(self, n):
		number_1 = str(n)
		number_2 = str(n * 2)
		number_3 = str(n * 3)
		if len(number_1) == 3:
			fasc_num = number_1 + number_2 + number_3
			if len(fasc_num) == 9 and ''.join(sorted(fasc_num)) == '123456789':
				return True
		return False


class Solution:

	def fascinating(self, n):
		if len(str(n)) < 3:
			return False
		concatenated = str(n) + str(n * 2) + str(n * 3)
		concatenated_digits = set(concatenated)
		if len(concatenated) == 9 and len(concatenated_digits) == 9 and ('0' not in concatenated):
			return True
		else:
			return False


class Solution:

	def fascinating(self, n):
		num = '123456789'
		mul2 = str(n * 2)
		mul3 = str(n * 3)
		final_mul = str(n) + mul2 + mul3
		counter = 0
		for i in num:
			if i in final_mul:
				counter += 1
		if counter == 9 and len(final_mul) == 9:
			return True
		else:
			return False


class Solution:

	def fascinating(self, n):
		a = n
		b = 2 * n
		c = 3 * n
		f = 0
		conc = str(a) + str(b) + str(c)
		for i in range(1, 10):
			if (str(i) in conc) & (conc.count(str(i)) == 1):
				f = 1
			else:
				f = 0
				break
		if f == 1:
			return 1
		else:
			return 0


class Solution:

	def fascinating(self, n):
		fascinating = True
		f = str(n * 2) + str(n * 3) + str(n)
		nums = [i for i in range(1, 10)]
		for num in nums:
			if f.count(str(num)) == 0 or f.count(str(num)) >= 2:
				fascinating = False
				break
		return fascinating


class Solution:

	def fascinating(self, n):
		p = [1, 2, 3, 4, 5, 6, 7, 8, 9]
		b = n * 2
		c = n * 3
		q = str(n) + str(b) + str(c)
		k = list(map(int, str(q)))
		k.sort()
		if k == p:
			return 1
		else:
			return 0


class Solution:

	def fascinating(self, n):
		digit = '123456789'
		d = str(2 * n)
		e = str(3 * n)
		c = str(n) + d + e
		cnt = 0
		for i in range(len(digit)):
			if digit[i] in c:
				cnt += 1
		if cnt == 9 and len(c) == 9:
			return True
		else:
			return False


class Solution:

	def fascinating(self, n):
		num = str(n) + str(n * 2) + str(n * 3)
		return '1' in num and '2' in num and ('3' in num) and ('4' in num) and ('5' in num) and ('6' in num) and ('7' in num) and ('8' in num) and ('9' in num) and (len(num) == 9)


class Solution:

	def fascinating(self, n):
		num = str(n) + str(n * 2) + str(n * 3)
		return '1' in num and '2' in num and ('3' in num) and ('4' in num) and ('5' in num) and ('6' in num) and ('7' in num) and ('8' in num) and ('9' in num) and (len(num) == 9)
if __name__ == '__main__':
	tc = int(input())
	while tc > 0:
		n = int(input().strip())
		ob = Solution()
		ans = ob.fascinating(n)
		if ans:
			print('Fascinating')
		else:
			print('Not Fascinating')
		tc -= 1


class Solution:

	def fascinating(self, n):
		n = str(n) + str(n * 2) + str(n * 3)
		if len(n) == 9 and all([i in n for i in '123456789']):
			return True
		return False


class Solution:

	def fascinating(self, n):
		second = n * 2
		third = n * 3
		result = str(n) + str(second) + str(third)
		reference = {}
		is_fascinating = True
		if len(result) != 9:
			is_fascinating = False
		if is_fascinating:
			for i in range(1, 10):
				if str(i) not in result:
					is_fascinating = False
		return is_fascinating


class Solution:

	def fascinating(self, n):
		s = str(n) + str(n * 2) + str(n * 3)
		for i in s:
			if s.count(i) > 1 or '0' in s:
				return 0
		return 1


class Solution:

	def fascinating(self, n):
		two = n * 2
		three = n * 3
		curb = ''
		crub = str(n) + str(two) + str(three)
		occ = 0
		for i in range(1, 10):
			if str(i) not in crub:
				return False
			elif str(i) in crub:
				occ += 1
		if occ == len(crub):
			return True
		else:
			return False


class Solution:

	def fascinating(self, n):
		if n > 333:
			return 0
		l = []
		a = n * 2
		b = n * 3
		n = n * 1000 + a
		n = n * 1000 + b
		while n > 1:
			l.append(int(n % 10))
			n = n / 10
		l.sort()
		for i in range(0, 9):
			if l[i] == i + 1:
				continue
			else:
				return 0
		return 1


class Solution:

	def fascinating(self, n):
		if len(str(n)) >= 3:
			x = str(n) + str(n * 2) + str(n * 3)
			l = []
			for i in x:
				l.append(i)
			l1 = ['1', '2', '3', '4', '5', '6', '7', '8', '9']
			if sorted(l) == l1:
				return True
			else:
				return False


class Solution:

	def fascinating(self, n):
		n1 = n * 2
		n2 = n * 3
		t = str(n) + str(n1) + str(n2)
		t1 = 123456789
		t2 = sorted(t)
		t2 = ''.join(t2)
		if t1 == int(t2):
			return True
		else:
			return False


class Solution:

	def fascinating(self, n):
		s = '123456789'
		n2 = n * 2
		n3 = n * 3
		s1 = str(n) + str(n2) + str(n3)
		s1 = sorted(s1)
		if s == ''.join(s1):
			return True
		return False


class Solution:

	def fascinating(self, n):
		num = str(n)
		prod2 = str(2 * n)
		prod3 = str(3 * n)
		concat = num + prod2 + prod3
		freq = {}
		for digit in concat:
			if digit != '0':
				freq[digit] = freq.get(digit, 0) + 1
		for i in range(1, 10):
			if str(i) not in freq or freq[str(i)] != 1:
				return False
		return True


class Solution:

	def fascinating(self, n):
		k = str(n)
		k += str(n * 2) + str(n * 3)
		l = ['1', '2', '3', '4', '5', '6', '7', '8', '9']
		for i in k:
			if i not in l or k.count(i) > 1:
				return False
		return True


class Solution:

	def fascinating(self, n):
		num = str(n)
		two_mul = str(n * 2)
		three_mul = str(n * 3)
		num1 = num + two_mul + three_mul
		l1 = ['1', '2', '3', '4', '5', '6', '7', '8', '9']
		l = list(num1)
		l.sort()
		if l == l1:
			return True
		else:
			return False


class Solution:

	def fascinating(self, n):
		if len(str(n)) >= 3:
			n1 = n * 2
			n2 = n * 3
			total = str(n) + str(n1) + str(n2)
			total_int = [int(i) for i in total]
			total_int.sort()
			for i in range(len(total_int)):
				if total_int[i] != i + 1:
					return 0
			return 1


class Solution:

	def fascinating(self, n):
		if n < 100:
			return False
		s1 = n * 2
		s2 = n * 3
		s3 = str(n) + str(s1) + str(s2)
		if len(s3) != 9:
			return False
		return set(s3) == set('123456789')


class Solution:

	def fascinating(self, n):
		a = str(n) + str(n * 2) + str(n * 3)
		return all([a.count('0') == 0, len(a) == len(set(a))])


class Solution:

	def fascinating(self, n):
		mine = list('123456789')
		mul2 = str(n * 2)
		mul3 = str(n * 3)
		result = list(str(n) + mul2 + mul3)
		result.sort()
		if mine == result:
			return True
		else:
			return False


class Solution:

	def fascinating(self, n):
		if n < 100 or n > 333:
			return False
		by2 = n * 2
		if by2 // 1000 != 0:
			return False
		by3 = n * 3
		if by3 // 1000 != 0:
			return False
		n = n * 1000 + by2
		n = n * 1000 + by3
		out = [0] * 10
		out[0] = 1
		for i in range(9):
			if out[n % 10] == 1:
				return False
			out[n % 10] = 1
			n = n // 10
		return True


class Solution:

	def fascinating(self, n):
		r = ['1', '2', '3', '4', '5', '6', '7', '8', '9']
		num = sorted(str(n) + str(n * 2) + str(n * 3))
		return r == num


class Solution:

	def fascinating(self, n):
		two = str(n * 2)
		three = str(n * 3)
		if ''.join(sorted(str(n) + two + three)) == '123456789':
			return True
		else:
			return False


class Solution:

	def fascinating(self, n):
		digits = '123456789'
		texto = str(n) + str(n * 2) + str(n * 3)
		if len(texto) > 9:
			return False
		for i in range(0, 9):
			digit = digits[i]
			if not texto.__contains__(digit):
				return False
		return True


class Solution:

	def fascinating(self, n):
		count = 0
		s = str(n) + str(n * 2) + str(n * 3)
		for i in range(1, 10):
			for j in s:
				if i == int(j):
					count = count + 1
			if count > 1 or count == 0:
				return False
			count = 0
		return True


class Solution:

	def fascinating(self, n):
		concat = str(n) + str(n * 2) + str(n * 3)
		concaat = list(concat)
		concaat.sort()
		if concaat == ['1', '2', '3', '4', '5', '6', '7', '8', '9']:
			return True
		else:
			return False


class Solution:

	def fascinating(self, n):
		s = [*str(n) + str(n * 2) + str(n * 3)]
		s.sort()
		for i in range(9):
			if i + 1 != int(s[i]):
				return False
		return True


class Solution:

	def fascinating(self, n):
		nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9']
		ans = ''
		ans += str(n)
		ans += str(n * 2)
		ans += str(n * 3)
		ans = sorted(ans)
		return ans == nums


class Solution:

	def fascinating(self, n):
		arr = [0] * 10
		no = n
		no2 = n * 2
		no3 = n * 3
		while no > 0:
			arr[no % 10] = arr[no % 10] + 1
			no = no // 10
		while no2 > 0:
			arr[no2 % 10] = arr[no2 % 10] + 1
			no2 = no2 // 10
		while no3 > 0:
			arr[no3 % 10] = arr[no3 % 10] + 1
			no3 = no3 // 10
		for i in range(1, 10):
			if arr[i] == 0 or arr[i] > 1:
				return False
		return True


class Solution:

	def fascinating(self, n):
		if n > 100:
			num_str = str(n) + str(n * 2) + str(n * 3)
			digits = list(num_str)
			return len(digits) == 9 and all((str(i) in digits for i in range(1, 10)))
		else:
			return False


class Solution:

	def fascinating(self, n):
		n = str(n) + str(n * 2) + str(n * 3)
		n = ''.join(sorted(n))
		if '123456789' == n:
			return True
		return False


class Solution:

	def fascinating(self, n):
		count = 0
		number = '123456789'
		a = n * 2
		b = n * 3
		c = str(a)
		d = str(b)
		e = str(n)
		f = c + d + e
		for i in number:
			if i in f:
				count += 1
		if count == 9 and len(f) == 9:
			return True
		else:
			return False


class Solution:

	def fascinating(self, n):
		lut = list('123456789')
		res = list(str(n) + str(n * 2) + str(n * 3))
		for d in lut:
			if res.count(d) != 1:
				return 0
		return 1


class Solution:

	def fascinating(self, n):
		n2 = n * 2
		n3 = n * 3
		a = str(n) + str(n2) + str(n3)
		ar = ['1', '2', '3', '4', '5', '6', '7', '8', '9']
		if sorted(a) == ar:
			return True
		else:
			return False


class Solution:

	def fascinating(self, n):
		n2 = n * 2
		n3 = n * 3
		ans = str(n) + str(n3) + str(n2)
		if len(ans) == 9:
			if str(1) in ans:
				if str(2) in ans:
					if str(3) in ans:
						if str(4) in ans:
							if str(5) in ans:
								if str(6) in ans:
									if str(7) in ans:
										if str(8) in ans:
											if str(9) in ans:
												return True
											else:
												return False


class Solution:

	def fascinating(self, n):
		times_two = n * 2
		times_three = n * 3
		fascinating = str(n) + str(times_two) + str(times_three)
		sorted_num = ''.join(sorted(fascinating))
		return sorted_num == '123456789'


class Solution:

	def fascinating(self, n):
		a = str(n)
		num1 = str(n * 2)
		num2 = str(n * 3)
		b = a + num1 + num2
		lst = []
		lst[:0] = b
		lst.sort()
		lst1 = ['1', '2', '3', '4', '5', '6', '7', '8', '9']
		if lst == lst1:
			return True
		else:
			return False


class Solution:

	def fascinating(self, n):
		ans = False
		x1 = str(n) + str(n * 2) + str(n * 3)
		for i in range(1, 10, 1):
			if str(i) in x1:
				if x1.count(str(i)) == 1:
					ans = True
				else:
					ans = False
					return ans
			else:
				ans = False
				return ans
		return ans


class Solution:

	def fascinating(self, n):
		result = str(n)
		if n < 101:
			return False
		else:
			result += str(n * 2) + str(n * 3)
			r = sorted(result)
			result = ''.join(r)
			if result == '123456789':
				return True
		return False


class Solution:

	def fascinating(self, n):
		n1 = n * 2
		n2 = n * 3
		new = str(n) + str(n1) + str(n2)
		l = []
		value = False
		for i in new:
			l.append(int(i))
		l = sorted(l)
		for i in range(1, 10):
			item = l.count(i)
			if item == 1:
				value = True
			else:
				value = False
				break
		if value:
			return 1
		else:
			return 0


class Solution:

	def fascinating(self, n):
		count = 0
		st = ['1', '2', '3', '4', '5', '6', '7', '8', '9']
		final_n = ''
		n1 = str(n * 2)
		n2 = str(n * 3)
		n3 = str(n)
		final_n = final_n + n1 + n2 + n3
		lst = list(final_n)
		lst.sort()
		for i in range(len(lst)):
			if lst == st:
				return True
			else:
				return False


class Solution:

	def fascinating(self, n):
		s = ''
		for i in range(1, 10):
			s += str(i)
		k = ''
		k += str(n)
		k += str(n * 2)
		k += str(n * 3)
		a = ''.join(sorted(k, key=str.lower))
		if a == s:
			return True
		else:
			return False


class Solution:

	def fascinating(self, num):
		if num < 100:
			return False
		num_str = str(num)
		num2_str = str(num * 2)
		num3_str = str(num * 3)
		concatenated = num_str + num2_str + num3_str
		if len(concatenated) != 9:
			return False
		digits = set(concatenated)
		return len(digits) == 9 and '0' not in digits


class Solution:

	def fascinating(self, n):
		n2 = n * 2
		n3 = n * 3
		last = str(n) + str(n2) + str(n3)
		num = '123456789'
		c = 0
		for i in num:
			if i in last:
				c += 1
		if c == 9 and len(last) == 9:
			return True
		else:
			return False


class Solution:

	def fascinating(self, n):
		if n < 100:
			return False
		n_str = str(n)
		concat_str = n_str + str(n * 2) + str(n * 3)
		digits_set = set(concat_str)
		if len(concat_str) == 9 and len(digits_set) == 9 and ('0' not in digits_set):
			return 'fascinating'
		else:
			return False


class Solution:

	def fascinating(self, n):
		s = str(n)
		if len(s) < 3:
			return False
		multi_two = n * 2
		multi_three = n * 3
		multi_two = str(multi_two)
		multi_three = str(multi_three)
		new_num = s + multi_two + multi_three
		if len(new_num) > 9:
			return False
		for i in range(1, 10):
			i = str(i)
			if i in new_num:
				continue
			else:
				return False
		return True


class Solution:

	def fascinating(self, n):
		x = str(n) + str(n * 2) + str(n * 3)
		if len(x) != 9:
			return False
		y = [True if str(i) in x else False for i in range(1, 10)]
		if False in y:
			return False
		else:
			return True


class Solution:

	def fascinating(self, n):
		s = n * 2
		t = n * 3
		s = str(s)
		t = str(t)
		n = str(n)
		d = n + s + t
		num = ['1', '2', '3', '4', '5', '6', '7', '8', '9']
		d = sorted(d)
		return d == num


class Solution:

	def fascinating(self, n):
		n1 = str(n * 2)
		n2 = str(n * 3)
		given = n1 + str(n) + n2
		target = '123456789'
		c = 0
		for i in target:
			if i in given:
				c += 1
		if c == 9 and len(given) == 9:
			return True
		else:
			return False


class Solution:

	def fascinating(self, n):
		d = '123456789'
		num = str(n) + str(n * 2) + str(n * 3)
		ans = ''.join(sorted(num))
		if ans == d:
			return True
		else:
			return False


class Solution:

	def fascinating(self, n):
		fas_ci = ['1', '2', '3', '4', '5', '6', '7', '8', '9']
		a = n * 2
		b = n * 3
		c = str(n) + str(a) + str(b)
		k = 0
		for i in fas_ci:
			if i not in c:
				k = k + 1
		for j in c:
			if c.count(j) > 1:
				k = k + 1
		if k == 0:
			return 1
		else:
			return 0


class Solution:

	def fascinating(self, n):
		s = n * 2
		t = n * 3
		result = str(n) + str(s) + str(t)
		d = dict()
		count = 0
		for i in range(1, 10):
			if result.count(str(i)) == 1:
				count += 1
		if count == 9 and len(result) == 9:
			return True
		else:
			return False


class Solution:

	def fascinating(self, n):
		b = str(n)
		c = n * 2
		d = n * 3
		e = str(n) + str(c) + str(d)
		l = ['1', '2', '3', '4', '5', '6', '7', '8', '9']
		l1 = list(sorted(e))
		return l1 == l


class Solution:

	def fascinating(self, n):
		ans = ['1', '2', '3', '4', '5', '6', '7', '8', '9']
		res = str(n) + str(n * 2) + str(n * 3)
		b = []
		b[:0] = res
		b.sort()
		if b == ans:
			return True
		else:
			return False


class Solution:

	def fascinating(self, n):
		a = n * 2
		b = n * 3
		string = str(n) + str(a) + str(b)
		arrStr = list(string)
		arrStr.sort()
		myList = []
		for i in range(1, 10):
			myList.append(str(i))
		if arrStr == myList:
			return True
		return False


class Solution:

	def fascinating(self, n):
		freq = [0] * 10
		A = str(n) + str(n * 2) + str(n * 3)
		for i in range(len(A)):
			digit = int(A[i])
			if freq[digit] and digit != 0 > 0:
				return False
			else:
				freq[digit] += 1
		for i in range(1, 10):
			if freq[i] == 0:
				return False
			elif freq[i] > 1:
				return False
		return True


class Solution:

	def fascinating(self, n):
		n = str(n)
		if len(n) >= 3:
			n = int(n)
			d = 2 * n
			t = 3 * n
			n = str(n) + str(d) + str(t)
			dt = {}
			for i in n:
				if i == '0':
					return False
				if i in dt:
					return False
				else:
					dt[i] = 1
			if len(dt) == 9:
				return True
		else:
			return False


class Solution:

	def fascinating(self, n):
		mul2 = n * 2
		mul3 = n * 3
		mul = str(n) + str(mul2) + str(mul3)
		mul = int(mul)
		a = []
		dig = 0
		while mul > 0:
			dig = mul % 10
			a.append(dig)
			mul = mul // 10
		a = sorted(a)
		if a == [1, 2, 3, 4, 5, 6, 7, 8, 9]:
			return True
		else:
			return False


class Solution:

	def fascinating(self, n):
		number = '123456789'
		result = str(n) + str(n * 2) + str(n * 3)
		count = 0
		for i in number:
			if i in result:
				count += 1
		if count == 9 and len(result) == 9:
			return 1
		return 0


class Solution:

	def fascinating(self, n):
		n1 = str(n) + str(n * 2) + str(n * 3)
		num = '123456789'
		cou = 0
		for i in num:
			if i in n1:
				cou = cou + 1
		if cou == 9 and len(n1) == 9:
			return 1
		return 0


class Solution:

	def fascinating(self, n):
		l1 = ['1', '2', '3', '4', '5', '6', '7', '8', '9']
		l2 = str(n) + str(n * 2) + str(n * 3)
		l3 = sorted(l2)
		if l1 == l3:
			return 1
		else:
			return 0