human
Maximum index a pointer can reach in N steps by avoiding a given index B | Set 2 | Function to find the maximum index the pointer can reach.
Initialize two pointers.
Stores number of steps.
Stores sum of first N natural numbers.
Increment i with j.
Increment j with 1.
Increment count.
If i points to B.
Break.
Print the pointer index.
Driver Code.
Given value of N & B.
Function call to find maximum index the pointer can reach"
Solution in Python:
assistant
#Here is code to maximum index a pointer can reach in N steps by avoiding a given index B and the other steps required.
 def maximumIndex ( N , B ) :
	i , j = 0 , 1
	cnt = 0
	sum = N * ( N + 1 ) // 2
	flag = False
	while ( cnt < N ) :
		i += j
		j += 1
		cnt += 1
		if ( i == B ) :
			flag = True
			break
	if ( not flag ) :
		print ( sum )
	else :
		print ( sum - 1 )
if __name__ == ' _ _ main _ _ ' :
	N , B = 4 , 6
	maximumIndex ( N , B )