Find Eventual Safe States - Leetcode 802 - Python