Your Dashboard
Interview Coaching
Learn
System Design
ML System Design
Code
Behavioral
Salary Negotiation
Interview Guides
Search
⌘K
Get Premium
Leetcode 3559. Number of Ways to Assign Edge Weights II
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).
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
All Regions
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.