On a staircase, the i-th step has some non-negative cost cost[i] assigned (0 indexed). Once you pay the cost, you can either climb one or two steps. You need to find * minimum cost *to reach the top of the floor, and you can either start from the step with

**index 0**, or the step with

**index 1**.

Input: Cost=[10,15,20]

Output: 15

def stairs(l): x,y=0,0 for i in l: x,y=i+min(x,y),x return min(x,y) l=list(map(int,input('Cost= ').split(' '))) print('Minimum Cost is: ',stairs(l)) ''' Alternative Method def stairs(l): for i in range(2,len(l)): l[i]+=min(l[i-1],l[i-2]) return min(l[len(l)-1],l[len(l)-2]) '''

**Morae**!Q!

- Insert and Extend in list
- Interchange first and last number in list
- Print Odd Numbers in range
- Compare List in python
- Find whether the largest element in the array is at least twice as much as every other number in the array.
- Find
to reach the top of the floor**minimum cost** - Word Count in Python
- Lower case to upper case in python
- Display Time in python
- Sum of Odd And Even in Python
- Surface Area of Walls
- Find the sum of squares of individual digits
- Print the given series – 1 1 2 6 24
- Minimum number of steps required to reach destination.
- Seconds to Days Hours Minutes
- Program to remove add “Hyphen” character in the entered string
- Remove the nth Index Character from a Non-Empty String
- Relational operator Question
- Check whether all the given numbers lies in range of x and y.
- Find the Armstrong numbers between the given range.