Infosys SP | Infosys Specialist Programmer | Graph Traversal & Divisibility | Recent Online Assessment Feb 2026 | Lucky Path Tree Problem

Infosys · Question · Posted Mar 2026

Question: Lucky Path Problem Statement: You are given a tree with N nodes rooted at node 1. Each node has an integer value value[i]. A lucky path is defined as a path from the root to any leaf such that the sum of all node values on that path is divisible by K. Find the total number of lucky paths in the tree. Notes: A tree is a connected acyclic graph with N nodes and N - 1 edges. Input ...

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

Log in Create a free account