Available question text
Count assignments on the simple path between two nodes so that the sum of edge weights (each either 1 or 2) is odd — equivalently you need an odd number of edges labeled 1, so for a path of k edges the answer is 0 if k=0 else 2^{k-1} mod 1e9+7; the algorithmic challenge is computing k (the distance in edges) quickly for many queries (e.g., with LCA/depth preprocessing).
Related questions
Continue with questions that share topics or the same question type.
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
No company association
Leetcode 3559. Number of Ways to Assign Edge Weights II
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source