Informatica Hiring | Minimum Time to Collect All Apples in a Tree | DFS | Off Campus OA 2025

Question · Posted Jun 2026

Problem Statement Given an undirected tree consisting of n vertices numbered from 0 to n - 1, rooted at node 0, and an array hasApple where hasApple[i] is true if vertex i contains an apple, determine the minimum time required to collect all apples in the tree and return back to the root node 0. You start at node 0. Moving along one edge takes 1 second. You must collect all apples present in the tree. After collecting all apples, ...

The full answer & interview discussion are available to premium members.

Log in Create a free account