Leetcode Weekly 381 | 3015,17 Count Number of Houses at Distance | Bharat Khanna, Guardian@Leetcode

Recently, we had a weekly 381 Leetcode Contest with 4 interesting problems.
This is the solution for second and fourth problem as they were variations of each other. We have discussed:
1. Brute Force - BFS from each node.
2. Pattern of graph having a cycle with chain of nodes attached
3. Handling different cases & compiling the solution.
Connect on Insta: / bharatkhanna1995
Connect on Linkedin: / bharat-khanna-717b4817b
00:00-04:11 Problem Statement
04:12-08:29 O(N^2) Brute Force
08:30-12:05 Calculating result for line of nodes
12:06-16:19 Handling head/tail to head/tail case
16:20-19:43 Handling head/tail to cycle case
19:44-23:44 Handling cycle to cycle case
23:45-37:28 Code

Пікірлер: 5

  • @user-sj3bn4pl4h
    @user-sj3bn4pl4h6 ай бұрын

    bhaiya, will you upload last biweekly contest video.

  • @CodingwithBharat

    @CodingwithBharat

    5 ай бұрын

    Hey, No I did not get enough time to cover that this week

  • @user-sj3bn4pl4h

    @user-sj3bn4pl4h

    5 ай бұрын

    @@CodingwithBharat okay

  • @sudhadevi6692
    @sudhadevi66926 ай бұрын

    I first apply Dijkstra for 2 😂 As n is small

  • @CodingwithBharat

    @CodingwithBharat

    6 ай бұрын

    Djikstra is for weighted graph and is more costly for unweighted one. That is why it is preferred to go for BFS when graph is unweighted

Келесі