Parallel Courses III - Leetcode 2050 - Python

SdĂ­let
VloĆŸit
  • čas pƙidĂĄn 24. 07. 2024
  • 🚀 neetcode.io/ - A better way to prepare for Coding Interviews
    đŸ„· Discord: / discord
    🐩 Twitter: / neetcode1
    🐼 Support the channel: / neetcode
    ⭐ BLIND-75 PLAYLIST: ‱ Two Sum - Leetcode 1 -...
    💡 DYNAMIC PROGRAMMING PLAYLIST: ‱ House Robber - Leetco...
    Problem Link: leetcode.com/problems/paralle...
    0:00 - Read the problem
    0:30 - Drawing Explanation
    6:50 - Coding Explanation
    leetcode 2050
    #neetcode #leetcode #python

Komentáƙe • 19

  • @siddhantpurohit216
    @siddhantpurohit216 Pƙed 9 měsĂ­ci +8

    Along with daily problems it will be great if you solved the weekly problems as well. Like to treat your solutions as benchmark !!

  • @MP-ny3ep
    @MP-ny3ep Pƙed 9 měsĂ­ci +2

    Was waiting for your solution. Thank you

  • @VidyaBhandary
    @VidyaBhandary Pƙed 9 měsĂ­ci

    Awesome !!! Thank you !! You may want to consider shifting to the old UI in leetcode for those questions where the diagrams are not clear.

    • @aditya-lr2in
      @aditya-lr2in Pƙed 9 měsĂ­ci

      that is an issue due to using dark mode and not the UI doe

  • @akash-kumar737
    @akash-kumar737 Pƙed 9 měsĂ­ci +2

    Dude I was able to solve this problem on my own. Came here to check if my solution is as efficient as yours. I would like to thank you for this. I always refer to your solution. Thanks a lot.

  • @mrunallachake6716
    @mrunallachake6716 Pƙed 7 měsĂ­ci

    Thank you for all the explanations making it easier to understand. Can you please make a video on Parallel Courses II?

  • @vikneshcs4824
    @vikneshcs4824 Pƙed 25 dny

    Here if the node 5 is reached from node 1 and cached the node 5 will return the cached value when trying to reach from node 2 right so how maxtime is updated here

  • @pi17
    @pi17 Pƙed 9 měsĂ­ci

    That's some motivation now.

  • @jatinkushwaha635
    @jatinkushwaha635 Pƙed 17 dny

    did the same thing in cpp got tle insted lol:(

  • @SkySentry7
    @SkySentry7 Pƙed 15 dny

    Here is a javascript solution using DFS & DP
    var minimumTime = function(n, relations, time) {
    const graph = Array(n+1).fill().map(() => [])
    const memo = {}
    let ans = 0
    for(const [prev,next] of relations){
    graph[prev].push(next)
    }
    const dfs = (node) => {
    if(memo[node]) return memo[node]
    let max_month = 0
    for(const adj of graph[node]){
    max_month = Math.max(max_month, dfs(adj))
    }
    memo[node] = max_month + time[node-1]
    return memo[node]
    }
    for(let node = 1; node

  • @sebascho4066
    @sebascho4066 Pƙed 9 měsĂ­ci

    Can anyone tell me whats this software for take notes?

    • @NeetCodeIO
      @NeetCodeIO  Pƙed 9 měsĂ­ci

      I use paint3d (windows only)

  • @varunaggarwal7126
    @varunaggarwal7126 Pƙed 9 měsĂ­ci

    its a simple toposort question.

  • @sidhanttiwari942
    @sidhanttiwari942 Pƙed 9 měsĂ­ci +1

    Ayooo, first???

  • @bablugupta2119
    @bablugupta2119 Pƙed 9 měsĂ­ci

    Can someone tell me java equivalent code?

    • @BERZERK_x
      @BERZERK_x Pƙed 9 měsĂ­ci

      Here it is, mate!
      class Solution {
      public int minimumTime(int n, int[][] relations, int[] time) {
      ArrayList adj = new ArrayList(n);

      for (int i = 0; i < n; i++) {
      adj.add(new ArrayList());
      }
      for(int[] el : relations) {
      adj.get(el[0] - 1).add(el[1] - 1);
      }
      int[] mxtime = new int[n];
      int ans = 0;
      for(int i = 0; i < n; i++) {
      ans = Math.max(ans, dfs(i, adj, time, mxtime));
      }
      return ans;
      }
      public int dfs(int curr, ArrayList adj, int[] time, int[] mxtime) {
      if(mxtime[curr] != 0) {
      return mxtime[curr];
      }
      int result = time[curr];
      for(int i : adj.get(curr)) {
      result = Math.max(result, time[curr] + dfs(i, adj, time, mxtime));
      }
      mxtime[curr] = result;
      return result;
      }
      }