Memory limit exceeded in leetcode problem number 802 Find Eventual safe states I tried to solve the question using topological sort using BFS . Here’s the code