human
Minimum cost to reach the top of the floor by climbing stairs | function to find the minimum cost to reach N - th floor.
declare an array.
base case.
initially to climb till 0 - th or 1 th stair.
iterate for finding the cost.
return the minimum.
Driver Code"
Solution in Python:
assistant
#Here is code to minimum cost to reach the top of the floor by climbing stairs and the other steps required.
 def minimumCost ( cost , n ) :
	dp = [ None ] * n
	if n == 1 :
		return cost [ 0 ]
	dp [ 0 ] = cost [ 0 ]
	dp [ 1 ] = cost [ 1 ]
	for i in range ( 2 , n ) :
		dp [ i ] = min ( dp [ i - 1 ] , dp [ i - 2 ] ) + cost [ i ]
	return min ( dp [ n - 2 ] , dp [ n - 1 ] )
if __name__ == " _ _ main _ _ " :
	a = [ 16 , 19 , 10 , 12 , 18 ]
	n = len ( a )
	print ( minimumCost ( a , n ) )