Largest Sum Cycle (GFG Hard, Juspay) Solved in ONE Pass | O(n) Explained | GFG POTD
Saurabh at Scale
0:00 / 0:00
Largest Sum Cycle (GFG Hard, Juspay) Solved in ONE Pass | O(n) Explained | GFG POTD
110 просмотров · 1 дн. назад
Saurabh at Scale
37 подписчиков
110 просмотров · 1 дн. назад
Largest Sum Cycle is a Hard GeeksforGeeks graph problem (tagged Juspay). In this video you learn the stamp trick that solves it in one pass, O(n) time and O(n) space, with no recursion. Beginner friendly, interview ready.
Problem: https://www.geeksforgeeks.org/problem...
Bonus: same idea solves LeetCode 2360, Longest Cycle in a Graph.
CHAPTERS
0:00 Can you solve this Hard problem in one pass?
0:15 The plan
0:32 The problem
0:47 What is a cycle?
1:07 When there is no cycle
1:23 The big clue: one arrow out
1:44 The slow brute force
2:06 The stamp trick
2:17 The three cases
2:42 The algorithm in 5 steps
3:09 Live trace
4:22 The code
4:54 Three traps (boolean visited, overflow, recursion)
5:27 Time and space complexity
5:48 How to nail it in an interview
6:17 Pause and solve quiz
6:30 Recap
6:49 Subscribe
Subscribe to @saurabhatscale for data structures and algorithms explained from beginner to advanced. Comment the next problem you want solved.
#dsa #graphs #geeksforgeeks #juspay #codinginterview #leetcode