human
Check if all sub | Function to calculate product of digits between given indexes.
Function to check if all sub - numbers have distinct Digit product.
Length of number N.
Digit array.
set to maintain digit products.
Finding all possible subarrays.
Driver Code"
How can the above be solved in Python?
assistant
#Here is code to check if all sub and the other steps required.
 def digitProduct ( digits , start , end ) :
	pro = 1
	for i in range ( start , end + 1 ) :
		pro *= digits [ i ]
	return pro
def isDistinct ( N ) :
	s = str ( N )
	length = len ( s )
	digits = [ None ] * length
	products = set ( )
	for i in range ( 0 , length ) :
		digits [ i ] = int ( s [ i ] )
	for i in range ( 0 , length ) :
		for j in range ( i , length ) :
			val = digitProduct ( digits , i , j )
			if val in products :
				return False
			else :
				products . add ( val )
	return True
if __name__ == " _ _ main _ _ " :
	N = 324
	if isDistinct ( N ) == True :
		print ( " YES " )
	else :
		print ( " NO " )