human
Find the count of unvisited indices in an infinite array | Function to return the count of unvisited indices starting from the index 0.
Largest index that cannot be visited.
Push the index to the queue.
To store the required count.
Current index that cannot be visited.
Increment the count for the current index.
( curr - m ) and ( curr - n ) are also unreachable if they are valid indices.
Return the required count.
Driver code"
How can the above be solved in Python?
assistant
#Here is code to find the count of unvisited indices in an infinite array and the other steps required.
 def countUnvisited ( n , m ) :
	i = 0
	X = ( m * n ) - m - n
	queue = [ ]
	queue . append ( X )
	count = 0
	while ( len ( queue ) > 0 ) :
		curr = queue [ 0 ]
		queue . remove ( queue [ 0 ] )
		count += 1
		if ( curr - m > 0 ) :
			queue . append ( curr - m )
		if ( curr - n > 0 ) :
			queue . append ( curr - n )
	return count
if __name__ == ' _ _ main _ _ ' :
	n = 2
	m = 5
	print ( countUnvisited ( n , m ) )