Course Schedule II | LeetCode 210 | C++, Java, Python

Поделиться
HTML-код
  • Опубликовано: 20 окт 2024
  • LeetCode Solutions: • LeetCode Solutions | L...
    June LeetCoding Challenge: • Playlist
    May LeetCoding Challenge: • Playlist
    Github Link: github.com/Kno...
    *** Best Books For Data Structures & Algorithms for Interviews:*********
    1. Cracking the Coding Interview: amzn.to/2WeO3eO
    2. Cracking the Coding Interview Paperback: amzn.to/3aSSe3Q
    3. Coding Interview Questions - Narasimha Karumanchi: amzn.to/3cYqjkV
    4. Data Structures and Algorithms Made Easy - N. Karumanchi: amzn.to/2U8FrDt
    5. Data Structures & Algorithms made Easy in Java - N. Karumanchi: amzn.to/2U0qZgY
    6. Introduction to Algorithms - CLR - Cormen, Leiserson, Rivest: amzn.to/2Wdp8rZ
    *****************************************************************************
    July LeetCoding Challenge | Problem 18 | Course Schedule II | 18 July,
    Facebook Coding Interview question,
    google coding interview question,
    leetcode,
    Course Schedule II,
    Course Schedule II c++,
    Course Schedule II Java,
    Course Schedule II python,
    Course Schedule II solution,
    210. Course Schedule II,
    #CodingInterview #LeetCode #JulyLeetCodingChallenge #Google #Amazon #CourseSchedule #TopologicalSort

Комментарии • 26

  • @bestsaurabh
    @bestsaurabh 3 года назад

    We can take an array of size = numCourses and fill it from last, keeping a track using an index.

  • @adrijaroy4499
    @adrijaroy4499 Год назад +1

    Sir your vids are really good, just that next time can you please start with JAVA? Just a personal request.

  • @TheMsnitish
    @TheMsnitish 4 года назад +2

    Dhanyawaad

  • @raj_kundalia
    @raj_kundalia Год назад +1

    thank you!

  • @pratyushranjansahu9495
    @pratyushranjansahu9495 4 года назад +2

    Can u plz have a look on Longest Palindromic substring (leet code 5). I have a doubt on that.

    • @KnowledgeCenter
      @KnowledgeCenter  4 года назад

      Posted my response there.
      "This is not Odd length. Odd and Even cases are for Odd and Even length palindrome and not input. Here palindrome is "bb", which is even."

  • @TheMsnitish
    @TheMsnitish 4 года назад +2

    Do you have any video explaining the basics of topological sorting ?

  • @potinmak1875
    @potinmak1875 3 года назад +1

    I wish I could be like you, who are so proficient in three programming languages (probably more) , I am only proficient in Java.

  • @swatygupta3753
    @swatygupta3753 4 года назад

    what is the time and space complexity?

  • @siddharthsingh4330
    @siddharthsingh4330 4 года назад +2

    why are we setting visited[u] = 2 in dfs?

    • @KnowledgeCenter
      @KnowledgeCenter  4 года назад +1

      2 means we are done with that node, and will never visit that again. These will also not be used for cycle detection.
      For more explanation check the video on Cycle Detection in Directed Graph, in the Graphs playlist. ruclips.net/video/1CdgY5KTQQE/видео.html

    • @siddharthsingh4330
      @siddharthsingh4330 4 года назад

      @@KnowledgeCenter oh got it. Thanks

  • @tusharjaiswal9480
    @tusharjaiswal9480 4 года назад +1

    for(int[] courses : prerequisites)
    adj[courses[1]].add(courses[0]); Can you explain this loop? Like how to read this?

    • @KnowledgeCenter
      @KnowledgeCenter  4 года назад +2

      [a, b] means course a is dependent on b. So, first take course b then course a.
      Or, there is an edge from b to a : b --> a
      So, a is in adjacency list of b.
      Here, a = courses[0], b = courses[1]

    • @tusharjaiswal9480
      @tusharjaiswal9480 4 года назад

      @@KnowledgeCenter Thanks alot!

  • @RishiRaj-dl1mg
    @RishiRaj-dl1mg 4 года назад +1

    Can't we do using bfs

    • @KnowledgeCenter
      @KnowledgeCenter  4 года назад +1

      Yes. Top. sort can be done using BFS also.

  • @BeatrizOliveira-yx4di
    @BeatrizOliveira-yx4di 4 года назад +3

    The C++ solution results in TLE

    • @BeatrizOliveira-yx4di
      @BeatrizOliveira-yx4di 4 года назад +1

      Sorry, I forgot to pass the adjancy list with an '&' in the function declaration