🚀 Day 141 of #100DaysOfCode with #GFG
Solved: Detect cycle in an undirected graph 🔄
📝 Used Union-Find (DSU) → if two vertices of an edge already share the same parent, a cycle exists. Otherwise, keep uniting sets.
#Java#DSA#CodingChallenge#gfg160#geekstreak2025
🚀 Day 140 of #100DaysOfCode
Solved the Rotten Oranges problem using BFS:
Multi-source BFS from all rotten oranges
Spread rot to neighbors in unit time
Track max time using cur.t
If fresh remain → return -1
#Java#DSA#Coding#gfg160#geekstreak2025
Day 139— Wrote BFS for Disconnected Graphs 🌐
Loop over all vertices → If unvisited, run BFS from it.
Uses a queue for level-order traversal & visited[] to avoid revisits 🔄
Works for both connected & disconnected graphs ✅
#Java#DSA#GraphAlgorithms#gfg160#geekstreak2025
Day 138
Implemented DFS Traversal for a connected undirected graph
Start from vertex 0, visit depth-first, follow adjacency list order exactly.
Recursive approach + visited[] to avoid cycles 🔄
#Java#DSA#GraphAlgorithms#gfg160#geekstreak2025
Day 138 of #160DaysOfCode — Implemented DFS Traversal for a connected undirected graph 🌐
Start from vertex 0, visit depth-first, follow adjacency list order exactly.
Recursive approach + visited[] to avoid cycles 🔄
#Java#DSA#GraphAlgorithms#gfg160#geekstreak2025