Find Eventual Safe States | Leetcode 802

Поділитися
Вставка
  • Опубліковано 27 січ 2025

КОМЕНТАРІ • 21

  • @kanirudh6820
    @kanirudh6820 День тому +2

    Actually i watched several videos but recently i noticed that always your way of explaining makes me understand things .Not everyone's cup of tea .Keep going bro🔥🔥

  • @theseshadesgucci9354
    @theseshadesgucci9354 3 дні тому +3

    nice explanation with illustrations ! keep up the good work man really appreciated

  • @pavanpandya9080
    @pavanpandya9080 3 дні тому

    Great Explanation.

  • @allwell8570
    @allwell8570 3 дні тому

    Best Explanation

  • @tejaschavan007
    @tejaschavan007 3 дні тому +2

    Grate Explanation💥

  • @YuelaiSu
    @YuelaiSu 3 дні тому

    Good explanation

  • @divypareek8230
    @divypareek8230 3 дні тому +1

    Great explanation sir

  • @sailendrachettri8521
    @sailendrachettri8521 3 дні тому +1

    Thank you sir :)

  • @Anikait-h3d
    @Anikait-h3d 3 дні тому +2

    it was difficult. had to see video multiple times. i still couldnt undertand why we are doing and operation on isSafe ,checkSafeState ans

    • @techdose4u
      @techdose4u  3 дні тому +1

      to optimise runtime.
      sane result of a node like in DP

  • @Marvel9-j4d
    @Marvel9-j4d 3 дні тому +6

    Today you uploaded late . 😢

    • @techdose4u
      @techdose4u  3 дні тому +1

      prediction of question dint work :)

  • @gypsygirlkigypsylife
    @gypsygirlkigypsylife 2 дні тому

    can u detect the error
    class Solution {

    public:
    vectorsafe_node;
    bool dfs(vector& graph,vector&visited,int i){
    visited[i]=1;
    bool is_safe=false;
    for(int neigh:graph[i]){
    if(visited[neigh]==0){
    is_safe&=dfs(graph,visited,neigh);
    }
    else if(visited[neigh]==1){//cycle
    return safe_node[i]=false;
    }
    else if(visited[neigh]==2){//already computed
    is_safe&=safe_node[neigh];
    }
    }
    visited[i]=2;
    return safe_node[i]=is_safe;
    }
    vector eventualSafeNodes(vector& graph) {
    int n=graph.size();
    safe_node=vector(n,true);
    vectorvisited(n,0);
    for(int i=0;i