Your Dashboard
Interview Coaching
Learn
System Design
ML System Design
Code
Behavioral
Salary Negotiation
Interview Guides
Search
⌘K
Get Premium
Leetcode 3558. Number of Ways to Assign Edge Weights I
Compute the maximum depth (number of edges) from root 1 to any deepest node in the tree, then count assignments of weights {1,2} on that root-to-deepest-node path that make the total sum odd. Because parity depends only on the number of 1s, the answer is the number of length-m binary sequences with an odd number of 1s, i.e., 2^{m-1} modulo 1e9+7 (m = max depth).
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.