Today I completed this playlist that i started 2 days back and I can't believe that seems to me very hard earlier is now feels to me like a normal hello world program and after I completed your BFS video starting from 1 video of playlist, after BFS i done all the question by myself without playing your video first ....Thanks alot May god bless you and wish this channel will be counted under the best education channels especially for CS engineers in upcoming 3 years.
Brother Question of LeetCode #207 Course Schedule , belongs to the concept of detecting a cycle in Directed Graph we can't do it using Non-Directed Graph .
I want to know where is parent updating , like initially we have assigned -1 as parent , so are we upadating it some where , nahi to it will keep parents as -1, if I am wrong please do correct me @ anyone!!!
yes u r on the right way of learning bus please ek baar code ko dry run karke dekho sach me mazaa aa jayega kissi v ek example ko aache se copy pen me write down kijiye
//my logic instead of tracking parent I use hashset to save the visited edge //if vertex is already visited but edge to that vertex not in hashiset then graph contains cycle //for more idea JAVA Code class Solution { // Function to detect cycle in an undirected graph. public boolean ans = false; public boolean isCycle(int V, ArrayList adj) { ans = false; HashSet hs = new HashSet(); boolean []visited = new boolean[V]; for(int i=0;i
class Solution { // Function to detect cycle in an undirected graph. dfs(current,parent,visited,adj,map){ if(visited[current] && map[parent] !== current) return 1 visited[current] =true let adjacent = adj[current] if(adjacent){ for(let i=0;i
Today I completed this playlist that i started 2 days back and I can't believe that seems to me very hard earlier is now feels to me like a normal hello world program and after I completed your BFS video starting from 1 video of playlist, after BFS i done all the question by myself without playing your video first ....Thanks alot May god bless you and wish this channel will be counted under the best education channels especially for CS engineers in upcoming 3 years.
Thanks udit bhai ...such a great motivation for me
Thank you so much, I was really scared to solve graph problems earlier, but now I am able to understand it and also solve them by myself.
The Best Graph Series, ❣️
Thanks bhai
Bhiya aap bhot shi tareeke se samjhate ho👍👍
😊😊 bass share karo do channel
you are making really great videos bro 👏👏
Thanks a lot shivansh 🤩
yes bhaiya maine ek ek function ko chaala chala ke dekha....literally clear ho gaya sab
waoo yaar aap sach me bhut hard working ho
@@HelloWorldbyprince thank u so much bhaiya
bhai sach me easy bana diya yaar tumne
Thank you bhaiya, nice explanation
balle balle ho gya 😁😁
Wahhh yaar good job
at #4:09 i had also the same thought process.....i analysed on my own why it will be wrong....but i couldn't come up with solution
koi baat nahi dhere dhere kar lega bro tum
not able to do that course schedule leetcode problem:
Brother Question of LeetCode #207 Course Schedule , belongs to the concept of detecting a cycle in Directed Graph we can't do it using Non-Directed Graph .
wahi toh , mai chutiya zabardasti dekh rha hu galti kaha hai .
Doesn't work on Leetcode 207 ?
I want to know where is parent updating , like initially we have assigned -1 as parent , so are we upadating it some where , nahi to it will keep parents as -1, if I am wrong please do correct me @ anyone!!!
yes u r on the right way of learning bus please ek baar code ko dry run karke dekho sach me mazaa aa jayega kissi v ek example ko aache se copy pen me write down kijiye
Brilliant explanation
Glad you think so!
sir aap best ho !!
also cp wala course enough hai ti get stated ??
what if there is a self loop?
thank you for your efforts
It's my pleasure
parent banane ka code konse line mein hai
Cpp Code -
bool DFS(vector adj[], vector&vis, int source, int parent){
vis[source]=true;
for(int x : adj[source]){
if(vis[x]==false){
if(DFS(adj,vis,x,source))
return true;
}
else if(x!=parent)
return true;
}
return false;
}
bool isCycle(int v, vector adj[]) {
// Code here
vector vis(v+1,false);
for(int i=0; i
Amazing yaar , keep learning
//my logic instead of tracking parent I use hashset to save the visited edge
//if vertex is already visited but edge to that vertex not in hashiset then graph contains cycle
//for more idea JAVA Code
class Solution {
// Function to detect cycle in an undirected graph.
public boolean ans = false;
public boolean isCycle(int V, ArrayList adj) {
ans = false;
HashSet hs = new HashSet();
boolean []visited = new boolean[V];
for(int i=0;i
Yeah u can do this as well nice 👍
Complete code -
bool h(vector adj[],vector &v,int s,int p)
{
v[s] = true;
for(auto x:adj[s])
{
if(!v[x])
{if(h(adj,v,x,s))
return true;}
else if( x!=p )
return true;
}
return false;
}
bool isCycle(int V, vector adj[])
{
vector v(V,false);
for(int i = 0; i < V; i++)
{ bool ans=false;
if(!v[i])
ans=h(adj,v,i,-1);
if(ans)
return true;
}
return false;
}
amazing bro
class Solution {
// Function to detect cycle in an undirected graph.
dfs(current,parent,visited,adj,map){
if(visited[current] && map[parent] !== current) return 1
visited[current] =true
let adjacent = adj[current]
if(adjacent){
for(let i=0;i
course schedule uses concept of cycle detection in Directed Graph...
Yo bro
bhai how parent is increasing?
you initialized parent=-1;
In recursive function calls, we are passing different parent for each call
👌weighted graph ke kuch karva do
Okay weighted graph ka v video banaa denge
Sir please upload krushkal algorithm class
sure i will
Bs bhai dsu pe video bana do
okay i will
Bhaiya isme jo question h uska solution nhi 41 test cases pass hue out of 51 and finally solution solve nhi ho pa rha h🥲
u can watch my solution as well
11/32 done (5.11.22)
good
-----------------------------------------------------------CODE-----------------------------------------------------
class Solution {
public:
bool DFS(vector adj[], int u, vector& visited, int parent)
{
visited[u] = true;
for(auto a: adj[u])
{
if(visited[a] == false)
{
if(DFS(adj, a, visited, u))
return true;
}
else if(a!=parent)
{
return true;
}
}
return false;
}
bool isCycle(int V, vector adj[]) {
vector visited(V+1, false);
for(int i = 0; i
amazing code bro nice
❤
👏 Thanks a ton
Playlist for Tree and DP plzz
sure
C++ CODE
// Function to detect cycle in an undirected graph.
bool DFSREC(int s, vector adj[],vector&visited,int parent)
{
visited[s]=true;
for(int u:adj[s])
{
if(visited[u]==false)
{
if(DFSREC(u,adj,visited,s))
return true;
}
else if(u!=parent)
{
return true;
}
}
return false;
}
bool isCycle(int V, vector adj[])
{
vectorvisited(V+1,false);
for(int i=0;i
good job
Bhaiya code is not working
For v=4 e = 3
4 2
1 2
2 3
#include
#include
#define V 4
using namespace std;
void edge(vectorgraph[],int i ,int j){
graph[i].push_back(j);
graph[j].push_back(i);
}
int check(vectorgraph[],vector&visited,int j,int prev){
visited[j]=1;
for(int i=0;i
nice buddy
at 5.55 krte he hum solve bhai
wait
bhai pura playlist taabadtod hai ,
Thanks bro for the support Please, share this channel in your college, groups, or LinkedIn bcoz it's cost nothing to you 😀
Please, share this channel in your college, groups, or LinkedIn bcoz it's cost nothing to you 😀