← Google questions

Longest path with same label in tree

Filed under Google

Given an undirected tree where each node has a label, find the length (number of edges) of the longest path where all nodes along the path have the same label.

You've read your 3 free write-ups

Sign up free to keep reading. Your account opens the first 10 questions of every company.

Related Google questions

Collected from public candidate posts and coding forums. Updated Nov 2026.