• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
October 19, 2023 |1.3K Views
PROBLEM OF THE DAY: 18/10/2023 | Eventual Safe States
Description
Discussion

Welcome to the daily solving of our PROBLEM OF THE DAY with Karan Mashru. We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of Data Structures and Algorithms but will also help you build up problem-solving skills.


In this problem, we are given a directed graph of V vertices and E edges in the form of an adjacency list adj. Each node of the graph is labeled with a distinct integer in the range 0 to V - 1.

A node is a terminal node if there are no outgoing edges. A node is a safe node if every possible path starting from that node leads to a terminal node.

You have to return an array containing all the safe nodes of the graph. The answer should be sorted in ascending order.

 

 

Give the problem a try before going through the video. All the best!!!

Problem Link: https://practice.geeksforgeeks.org/problems-preview/eventual-safe-states/1

Solution Function Link: https://ide.geeksforgeeks.org/online-cpp-compiler/4dee4800-21a1-4e89-b637-f34dc69bd395