Back to problems

Find maximum follow depth using recursion

Algorithm · Roblox · Hard

Consider a social graph formed by directed follow relationships. Every tuple (follower_id, followee_id) in follows means that follower_id follows followee_id. For a given starting user start_id, follow the outgoing edges repeatedly: layer 1 consists of users directly followed by start_id, layer 2 consists of users followed by those users, and so on. Return the largest layer that can be reached. Equivalently, return the number of edges on the longest directed path that begins…

Checking your access…