Razorpay SDE-1 OA | Tree Contribution Technique & 3D Knapsack DP

Razorpay · Question · Posted Jun 2026

Problem 1 - Edge Strength Problem Statement You are given a weighted tree containing N nodes and N - 1 edges. The strength of the tree, denoted by E, is defined as: E = Σ F(i, j) for all pairs 1 ≤ i < j ≤ N. Where: F(i, j) = maximum edge weight present on the simple path between node i and node j. Your task is to calculate and return the total tree strength. Constraints Constraint 1 ≤ ...

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

Log in Create a free account