Leetcode 746. Min Cost Climbing Stairs

Поділитися
Вставка
  • Опубліковано 12 лис 2024

КОМЕНТАРІ • 28

  • @8bit_hero850
    @8bit_hero850 2 роки тому

    c++ solution:
    int minCostClimbingStairs(vector& cost) {
    for(int i=cost.size()-3;i>=0;i--)
    cost[i]=min(cost[i]+cost[i+1],cost[i]+cost[i+2]);
    return min(cost[0],cost[1]);
    }

  • @ring0894
    @ring0894 2 роки тому +1

    No matter how much i look at the solution i just cant understand why this is why i struggle with solving leetcode problems

  • @AINikunjGour
    @AINikunjGour 2 роки тому

    great bro plz upload more videos

  • @srishtijaiswal7079
    @srishtijaiswal7079 2 роки тому

    Got a good youtube video on dp👍🙏 thank you
    Bhaiya

  • @Mandeepsingh-jo5cf
    @Mandeepsingh-jo5cf 3 роки тому

    thanks.

  • @jbbanerjee8534
    @jbbanerjee8534 3 роки тому +7

    Best video on a DP problem !! It shows not only the solution but the entire thought process behind solving the problem. Keep up the good work .

  • @abhinavsingh9720
    @abhinavsingh9720 3 роки тому +1

    As clear as crystal.

  • @adithibhat7277
    @adithibhat7277 2 роки тому

    This is so awesome. Thank you...

  • @hiteshwasdani9545
    @hiteshwasdani9545 3 роки тому

    big thumps up

  • @vigneshm05
    @vigneshm05 3 роки тому

    Best Explanation for this problem!

  • @fazlerabbi2666
    @fazlerabbi2666 3 роки тому +2

    great explanation. just one question. what is the thought process to convert top down approach to a bottom down approach? i struggle to make this conversion

    • @AINikunjGour
      @AINikunjGour 2 роки тому

      same problem

    • @amoldeshpande3877
      @amoldeshpande3877 2 роки тому

      def minCostClimbingStairs(self, cost: List[int]) -> int:
      def find_min_cost(i,memo={}):
      if i in memo:
      return memo[i]
      if i < 0:
      return 0
      if i == 1 or i == 0:
      return cost[i]
      memo[i] = cost[i] + min(find_min_cost(i-1),find_min_cost(i-2))
      return memo[i]
      return min(find_min_cost(len(cost)-1),find_min_cost(len(cost)-2))
      I feel this is the right way to solve by top down approach.
      @Lead Coding by FRAZ

  • @ankitkumarghosh462
    @ankitkumarghosh462 3 роки тому

    Great explanation

  • @akshatmahajan2692
    @akshatmahajan2692 2 роки тому

    really struggling in Dp problems please create a dp playlist if u can that will be more helpful

  • @kulsumbegum2063
    @kulsumbegum2063 3 роки тому

    Thanks for this great explanation!

  • @yatharthbajaj3978
    @yatharthbajaj3978 3 роки тому

    doing great job!

  • @WiFiWaLaaa
    @WiFiWaLaaa Рік тому

    NoT Any Space.................!
    TC O(n)
    class Solution {
    public int minCostClimbingStairs(int[] cost) {
    for (var i = cost.length-3; i >= 0; i--)
    cost[i] += Math.min(cost[i+1], cost[i+2]);
    return Math.min(cost[0], cost[1]);
    }
    }
    // optimised

  • @shaheenrafiq5974
    @shaheenrafiq5974 3 роки тому +2

    The explanation was so clear! Thank you so much for such a detailed explanation.
    Subscribed immediately :)

    • @mohammadfraz
      @mohammadfraz  3 роки тому

      Welcome! and thanks for subscribing

  • @MilindGupta
    @MilindGupta 3 роки тому +1

    Hey i wanted to ask you like I am in 2nd year nd I am too doing 2 leetcode problem everyday and 2 cp problem...
    What should I do to improve my problem solving skills
    And is it too late to start now

    • @mohammadfraz
      @mohammadfraz  3 роки тому +1

      You are doing good. Just be consistent and it's not late

  • @vijayarana8208
    @vijayarana8208 2 роки тому

    Thanks for this great explanation!